Giter Site home page Giter Site logo

Followers count about twitter-api-php HOT 6 CLOSED

j7mbo avatar j7mbo commented on August 23, 2024
Followers count

from twitter-api-php.

Comments (6)

J7mbo avatar J7mbo commented on August 23, 2024

According to the docs:

The resource URL you need is: https://api.twitter.com/1.1/users/show.json
The getfield is: ?screen_name=YOURNAME
It's a GET request

In the response, you should be able to access it by:

$response->followers_count. More information on this page.

from twitter-api-php.

ZERGE avatar ZERGE commented on August 23, 2024

Thanks for the tips.

I'm trying to use:

$twitter = new TwitterAPIExchange($settings);
$response = $twitter->setGetfield($getfield)
                    ->buildOauth($url, $requestMethod)
                    ->performRequest();

echo $response->followers_count;

but get an error:

Notice: Trying to get property of non-object in ... line "echo $response->followers_count;"

from twitter-api-php.

J7mbo avatar J7mbo commented on August 23, 2024

The response is in JSON, so you need to json_decode() it before trying to access the property.

from twitter-api-php.

ZERGE avatar ZERGE commented on August 23, 2024

Yep. Got it :)

$followers = json_decode($response);
echo $followers->followers_count;

from twitter-api-php.

LukeXF avatar LukeXF commented on August 23, 2024

Would you mind uploading your code @ZERGE?

from twitter-api-php.

lmj0011 avatar lmj0011 commented on August 23, 2024

@J7mbo you saved me some frustration man. Was forgetting to use json_decode() while trying to access the response's values

from twitter-api-php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.