How To Get Mobile Recharge API?

How can I get the Twitter following status without overriding the rate limit of the Twitter API?

  • I want to have all my followers divided in three columns. One column for people who I follow, but who do not follow me back. One for people who follow me, but I don't follow them. And one column for mutually following. Right now I try to get all my followers at once. After that I get all the people who I follow. After that I compare the lists and decide for each follower in which column he or she belongs. The downside of this method is that it takes a long time for people with lots of followers (more than 2000 for example). I want to have something like paging, but that isn't possible, since I have to have all my followers and all the people who I follow in order to compare them. So there's got to be another way, which gives me the following status in a more efficient way, without overriding the rate limit. Maybe the streaming API (I'm using the rest api), but I think it's not possible to get that information through that API.

  • Answer:

    The most efficient pattern for this requires only 2 API calls in most cases. You want to use these two API methods: GET http://api.twitter.com/1/friends/ids.json GET http://api.twitter.com/1/followers/ids.json You'll want to use the "cursor" feature of these methods -- it'll let you retrieve up to 5000 results per "page/cursor" per method. You then compare the results of these lists of integers -- the intersection are the mutual followers, those in followers/ids but not in friends/ids are those you don't follow who follow you, and those in friends/ids but not in followers/ids are the ones you follow that don't follow you back. Now you have the facts by reference. If you wanted to further investigate who these users are, you'd then make additional requests to GET users/lookup with arrays of user_ids to convert into fully-hydrated user objects. Documentation on these methods: http://dev.twitter.com/doc/get/followers/ids http://dev.twitter.com/doc/get/friends/ids http://dev.twitter.com/doc/get/users/lookup This pattern is very efficient -- for those few users with more than 5000 followers or followings, the increase in the amount of API requests is pretty manageable. For some rare edge cases it might take more API calls than you can make in an hour, but you would just have to accept that it'd take additional time.

Taylor Singletary at Quora Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.