【问题标题】:Twitter streaming api limit countTwitter 流媒体 API 限制计数
【发布时间】:2011-10-11 12:34:46
【问题描述】:

我正在尝试访问 twitter 流 api,但是我想限制收到的回复数量,我尝试使用 count 参数:

https://user:pass@stream.twitter.com/1/statuses/sample.json?count=100

但我得到了错误:

Parameter count not allowed in role statusSpritzer 

谁能解释为什么不允许这样做?

我尝试使用的代码是这样的:

$url = "https://user:pass@stream.twitter.com/1/statuses/sample.json";
$fp = fopen($url,"r");

while($data = fgets($fp)){
    $decode = json_decode($data);               
    for($i = 0; $i < count($decode); $i++){         
        echo $decode->$i;
    }       
}

但由于返回的推文数量太长,处理时间太长,所以我试图限制数量..

【问题讨论】:

    标签: php api twitter


    【解决方案1】:

    尝试将sample.json 更改为user_timeline.json

    https://user:pass@stream.twitter.com/1/statuses/user_timeline.json?count=100

    更多信息可以在这里找到:
    https://dev.twitter.com/docs/api/1/get/statuses/user_timeline

    编辑:Spritzer 访问级别似乎不允许这样做。 Count 只能用于 Gardenhose 访问级别。

    引用:

    注意count参数在其他地方是不允许的,包括track、sample和在默认访问角色上。

    来自https://dev.twitter.com/docs/streaming-api/methods#count

    因此,虽然 statuses/sample 允许使用 count 参数,但它不允许使用 Spritzer 的默认访问级别。

    【讨论】:

    • 谢谢,但我想要的是流式传输的随机推文数据,而不是我的数据。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-29
    • 2011-05-06
    • 2015-03-15
    相关资源
    最近更新 更多