如何使用Twitter的API来在单个请求中获得超过20名会员? [英] How to use Twitter Api To Get more than 20 list Members in a single request?

查看:205
本文介绍了如何使用Twitter的API来在单个请求中获得超过20名会员?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Twitter的API超过20个用户在单个请求
有没有指定任何参数?

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

我使用这个API
http://api.twitter.com/1/Barelyme/政治/ members.xml?光标= -1

推荐答案

如果您正在使用 twitteroauth的/一>,您可以通过列表成员的迭代页面(本示例假定$连接已经被一个功能的实现twitteroauth的定义):

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"
    }
}

这篇关于如何使用Twitter的API来在单个请求中获得超过20名会员?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆