简体   繁体   English

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

[英]Search by hashtag Twitter API v1.1 - No Returns Old Results

I'm doing a search for hashtags using the new api Twitter (v 1.1) and it works for some results. 我正在使用新的api Twitter(v 1.1)搜索主题标签,它可以用于一些结果。 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? 谁能帮我?

From dev.twitter.com 来自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. 请注意,Twitter的搜索服务以及扩展名为Search API并不是Tweets的详尽来源。 Not all Tweets will be indexed or made available via the search interface . 并非所有推文都会通过搜索界面编入索引或提供

I hope this was helpful 我希望这可以帮到你

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM