Twitter API: Get Followers +99

前端 未结 7 844
悲&欢浪女
悲&欢浪女 2021-02-06 08:05

Using the twitter API (and OAuth) if i was to call for the user followers, (statuses/followers) i would be returned only 99 results.

Is there a way i can return 99, then

7条回答
  •  醉酒成梦
    2021-02-06 08:49

    Though I asked this quite a while ago, I came back to building something quite similar recently (+ new programming skills).

    I noticed Twitter API have a method to get all of a users followers (or followings) user ID's in one request. I found the best way was to array_chunk up the ID's into batches of 100 (and only take the first 30 arrays as I dont want to use all the users api requests that hour - they might want to actually tweet!). Then there is a method that allows you to get up to 100 users userinfo (from the view of the currently authenticated user) so I just do a loop (sleep a bit inbetween) and then you've got 30,000 twitter followers!

    I would recommend doing this asynchronously in a queue system, as if you do this on the fly when the users requests a page on the site it could be very slow and you might be prone to a HTTP timeout. Also cache them like hell!

    Sorry I didn't post any code, but hopefully this thought process will help someone :)

提交回复
热议问题