簡體   English   中英

Twitter搜索API v1.1無法正常工作

[英]Twitter Search API v1.1 not working

我正在使用Twitter Search API v1.1來簡單地按#monstercareers標簽進行搜索。 此代碼段適用於其他主題標簽,但不適用於此特定標簽。 我知道此API與Twitter實際使用的API略有不同(這使得測試變得困難),但是如果您在Twitter.com上搜索#monstercareers,它就可以正常工作。

<?php

  require_once('lib/TwitterAPIExchange.php');

  $url = "https://api.twitter.com/1.1/search/tweets.json";
  $getfield = "?q=#monstercareers";
  $requestMethod = "GET";

  $settings = array(
    'oauth_access_token' => "xxx",
    'oauth_access_token_secret' => "xxx",
    'consumer_key' => "xxx",
    'consumer_secret' => "xxx"
  );

  $twitter = new TwitterAPIExchange($settings);
  echo $twitter->setGetfield($getfield)->buildOauth($url, $requestMethod)->performRequest();

?>

這是上面代碼產生的空響應:

{
  statuses: [ ],
  search_metadata: {
   completed_in: 0.006,
   max_id: 396701092337053700,
    max_id_str: "396701092337053696",
    query: "%23monstercareers",
    refresh_url: "?since_id=396701092337053696&q=%23monstercareers&include_entities=1",
    count: 15,
    since_id: 0,
    since_id_str: "0"
   }
}

有誰知道為什么這可能會導致不一致,以及是否有更好的解決方法?

通過做一些研究,我發現twitter API最多只能回溯6-9天的推文,因此,在您可能想按時回顧的情況下,您需要使用until參數。

在“最佳做法”部分的https://dev.twitter.com/docs/using-search上查看文檔。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM