通过一个请求检索所有推特关注者


Retrieving all twitter followers with a single request

我试过这个,甚至添加了一个游标,但它仍然只会检索前 100 个关注者。

<?php
$cursor = -1;
$account_from = 'username';
do
  {
     $json = file_get_contents('http://api.twitter.com/1/statuses/followers/' .   $account_from .'.json?cursor=' . $cursor);
$accounts = json_decode($json);
foreach ($accounts->users as $account)
{
        $a[] = $account->screen_name ; 

}
$cursor = $accounts->next_cursor;

}
 while ($cursor > 0);
 foreach($a as $f) {
         echo $f ; 
   }

?>

有没有更好、更简单的方法?我哪里出错了?请帮忙?

API 文档声明此请求已弃用:

此方法已弃用,因为它只会返回有关最近发推的用户的信息。这不是检索所有用户关注者的功能方法。不使用此方法,请使用GET关注者/ID和GET用户/查找的组合。

请改用此 API:https://dev.twitter.com/docs/api/1/get/followers/ids

您的对象中应该有一个名为 next_cursor 的属性,只要它不为零,请继续再次执行请求(指定该光标),直到获得所有结果。