Codebird php下一个光标重复结果

时间:2014-08-02 19:05:57

标签: php

我遇到了一个愚蠢的问题。我正在尝试使用codebird php(twitter api 1.1)列出我的粉丝,我每次都会重复搜索结果:

public function getFollowers(){
     $this->client->setToken($_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
     $fol=$this->client->followers_list();
     $cursor=-1;
     $cursor=$fol->next_cursor_str;
if($cursor > 0){
    $followers=(array)$this->client->followers_list('cursor=' . $cursor);
 //  var_dump($followers);
    }

     for($i=0;$i<count($followers) ;$i++){
          echo "<p>";
          echo "<img src=\"". $followers['users'][$i]->profile_image_url. "\" />";
          echo "<a href=\"https://twitter.com/". $followers['users'][$i]->screen_name. "\""." target=\"_blank\" >" ."<b>".$followers['users'][$i]->screen_name."</b>"."</a><br/>";
          echo "</p>";
          echo "<p class=\"desc\">". $followers['users'][$i]->description . "<p>";
          echo "<p class=\"info\">"."Seguidores : ".$followers['users'][$i]->followers_count ." "."Siguiendo : ".$followers['users'][$i]->friends_count." "."Tweets : ".$followers['users'][$i]->statuses_count ;
          } 
    }

1 个答案:

答案 0 :(得分:0)

增加光标

$nextCursor = $reply->next_cursor_str;

while ($nextCursor > 0) {

$followers= (array) $reply;


 for($i=0;$i<count($followers) ;$i++){
          echo "<p>";
          echo "<img src=\"". $followers['users'][$i]->profile_image_url. "\" />";
          echo "<a href=\"https://twitter.com/". $followers['users'][$i]->screen_name. "\""." target=\"_blank\" >" ."<b>".$followers['users'][$i]->screen_name."</b>"."</a><br/>";
          echo "</p>";
          echo "<p class=\"desc\">". $followers['users'][$i]->description . "<p>";
          echo "<p class=\"info\">"."Seguidores : ".$followers['users'][$i]->followers_count ." "."Siguiendo : ".$followers['users'][$i]->friends_count." "."Tweets : ".$followers['users'][$i]->statuses_count ;
          } 


$reply= $cb->followers_list('cursor=' . $nextCursor);

$nextCursor = $reply->next_cursor_str;

}
相关问题