Reputation: 2143
As the twitter has updated its API recently, how can I get the number of followers of a person?
I could get such data with old API using following, but if I understand correctly, it will stop working at any time.
http://api.twitter.com/1/statuses/user_timeline.json?screen_name=twitter
How can I get the same data using their new API? I have checked their documentation but could not understand.
Upvotes: 1
Views: 1313
Reputation: 2612
Yes, it is confusing. I did this recently for a client and it took me a while to figure out.
Read this: https://dev.twitter.com/docs/auth/application-only-auth
To comply with v1.1 and get the data you want, you'll need to create a twitter application through your twitter account. The application will give you a couple of access keys. You'll use those access keys to obtain an access token, which you use to fetch your public data.
Here is the implementation I used: https://gist.github.com/luk3thomas/5243493
Upvotes: 1
Reputation: 50787
Well straight from the new documentation it would seem the biggest difference is using 1.1
instead of 1
You still retreive the data using JSON -
https://api.twitter.com/1.1/statuses/user_timeline.json
The docs say that the requirements are:
Always specify either an user_id or screen_name when requesting a user timeline.
And the returned object contains a "user" object, which contains the followers_count
key:value pair.
{
{
......
user: {
.....
"followers_count" : int
}
}
}
Upvotes: 1