【问题标题】:twitter api get only 196 tweetstwitter api 仅获得 196 条推文
【发布时间】:2018-02-11 02:10:36
【问题描述】:

我正在使用 laravel 5 和 twitter api thujohn/twitter 一切都很好,除了不能获得超过 196 条推文 这是我在 TweetController 中的功能

public function tweet() 
{ 
    $contents = array();
    $limit = 3200;
    $max_id = null;
    for($count=200 ; $count < $limit ; $count+=200)
    {
        if(null !== $max_id && $max_id == ''){
            break;
        }

        $content = Twitter::getFavorites([
            'count'=>$count,'screen_name'=>'k.s.a95','cursor'=>$max_id,'format'=>'array'
        ]);

        $contents[] = (array)$content;

        //$max_id = $content[count($content) - 1]->id_str;
        if(count($content))
        {
            $last_tweet = end($content);
            $max_id = $last_tweet->next_cursor_str;
             print_r($content);
        } else $max_id = null;

    }
}

我希望能帮上忙,这是我第三次要求没有回应

【问题讨论】:

    标签: twitter-bootstrap api laravel-5 twitter twitter-oauth


    【解决方案1】:

    如果您使用read the documentation,您会发现count 并不总是准确的。

    最好将 count 的值视为对要返回的推文数量的限制,因为在应用计数后会删除暂停或删除的内容。

    【讨论】:

    • 我该如何处理 max_id ?
    • 你不能。计数有时会少于 200。抱歉。
    • 误会了,不管是 200 还是 196 我都需要循环完成所有推文。
    • 不用担心 max_id - 继续使用光标。
    • 我用了你在上面的代码中看到的,但仍然无法得到它。
    猜你喜欢
    • 2015-02-21
    • 1970-01-01
    • 2013-01-03
    • 1970-01-01
    • 2013-06-07
    • 2018-03-12
    • 1970-01-01
    • 2011-08-02
    相关资源
    最近更新 更多