1

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.

2 Answers 2

1

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
        }
    }
}
Sign up to request clarification or add additional context in comments.

2 Comments

Type this: https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=twitterapi&count=2 and you will get error. I think it requires the authentication, but I do not know how to use that.
@user1251698 straight from the link on the right under 'RESOURCE INFORMATION', it says, 'Authencation : REQUIRED'. Clicking on that link takes you to the oAuth page...it has v1 and v1.1 requirements, clicking the sublink Application-only authentication. It says you create your application here which is where you will be assigned your consumer key and secret key. From there, you can use the documentation, again in order to finish.
1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.