How to use Twitter Api To Get more than 20 list Me

2019-04-01 01:30发布

i want to get more than 20 users using the the twitter api in a single request is there any parameter that specifies it?

i am using this api http://api.twitter.com/1/Barelyme/Politics/members.xml?cursor=-1

标签: api twitter
4条回答
混吃等死
2楼-- · 2019-04-01 01:58

According to the Twitter List API Docs:
http://apiwiki.twitter.com/Twitter-REST-API-Method:-GET-list-members

You cant get more than 20 in a single request.

查看更多
forever°为你锁心
3楼-- · 2019-04-01 02:00

If you're using twitteroauth by abraham, you can iterate through the pages of list members (this example assumes $connection is already defined by a functional implementation of twitteroauth):

$user = $connection->get('account/verify_credentials'); //Gets/Tests credentials
$listmembers = $connection->get("{$user->screen_name}/LISTNAMEORID/members"); //Gets first page of list members; MUST edit "LISTNAMEORID"
$pagevalue = ""; //Set page value for later use

if($listmembers->next_cursor == 0){ //There is only one page of followers
    for ($j=0, $k=count($listmembers->users); $j<$k; $j++){
        //Your actions here
        //print_r($listmembers); //Displays the page of list members
    }
} else { //There are multiple pages of followers
    while ($pagevalue!=$listmembers->next_cursor){
        for ($j=0, $k=count($listmembers->users); $j<$k; $j++){
            //Your actions here
            //print_r($listmembers); //Displays the page of list members
        }
        $pagevalue = $listmembers->next_cursor; //Increment the 'Next Page' link
        $listmembers = $connection->get("{$user->screen_name}/LISTNAMEORID/members", array('cursor' => $pagevalue)); //Gets next page of list members; MUST edit "LISTNAMEORID"
    }
}
查看更多
劳资没心,怎么记你
4楼-- · 2019-04-01 02:15
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
$listmembers = $connection->get("MexicoTimes/mexicanpoliticians/members");
$members = array();
while ($listmembers->next_cursor_str != "0") {
    foreach($listmembers->users as $user)
        $members[] = $user;
    $cursor = $listmembers->next_cursor_str;
    $listmembers = $connection->get("MexicoTimes/mexicanpoliticians/members", array('cursor' => $cursor));
}

This one worked for me with Abraham's Twitteroauth

查看更多
老娘就宠你
5楼-- · 2019-04-01 02:22

Probably not though, you can poll multiple times > 1 for more data.

Given that twitter said you can't do it, you Probably can't

查看更多
登录 后发表回答