dongpai6567 2013-08-13 21:21
浏览 57
已采纳

按主题标签搜索Twitter API v1.1 - 否返回旧结果

I'm doing a search for hashtags using the new api Twitter (v 1.1) and it works for some results. But for older tweets do not return a result.

My code:

    $this->load->library("TwitterAPIExchange", $settings);

    /** Perform the request and echo the response **/
    $twitter = new TwitterAPIExchange($settings);

    /** URL for REST request, see: https://dev.twitter.com/docs/api/1.1/ **/
    $url = "https://api.twitter.com/1.1/search/tweets.json";
    $requestMethod = "GET";

    //hashtag
    $hashtag = "#vmb2012";
    //Method search parameters GET
    $getfield = "?q=$hashtag&result_type=mixed&count=100";
    //Counter tweets
    $count = 0;

    /** Search global tweets for a hashtag **/
    $result = json_decode( $twitter->setGetfield($getfield)->buildOauth($url, $requestMethod)->performRequest() );      

    if(!empty($result))
    {
        //increases the qty of tweets
        $count = isset($result->statuses) ? count($result->statuses) : 0;

        //if you have more results, performs the query again                                
        while($result->search_metadata && isset($result->search_metadata->next_results))
        {
            //search parameters of the next result
            $getfield = $result->search_metadata->next_results;
            $result = json_decode( $twitter->setGetfield($getfield)->buildOauth($url, $requestMethod)->performRequest() );
            $count += count($result->statuses);             
        }                   
    }

    echo "Hashtag: ".$hashtag." <br>";
    echo "Counter: ".$count;

can anyone help me?

  • 写回答

1条回答 默认 最新

  • dsij89625 2013-08-13 21:54
    关注

    From dev.twitter.com

    Please note that Twitter's search service and, by extension, the Search API is not meant to be an exhaustive source of Tweets. Not all Tweets will be indexed or made available via the search interface.

    I hope this was helpful

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 R语言卸载之后无法重装,显示电脑存在下载某些较大二进制文件行为,怎么办
  • ¥15 java 的protected权限 ,问题在注释里