dongzhun1857 2019-03-11 08:38
浏览 37
已采纳

Api twitter响应无状态

I'm trying to display tweets for a specific hashtag. The code below works perfectly what ever the hashtag is, but when i try with the specific one, it doesn't work. For the last month, it worked perfectly with the right hashtag but since yesterday it's broken. (i didn't put my tokens in the code)

require_once('twitter-api-php-master/TwitterAPIExchange.php');

/** Set access tokens here - see: https://dev.twitter.com/apps/ **/
$settings = array(
    'oauth_access_token' => "my_tokens",
    'oauth_access_token_secret' => "my_tokens",
    'consumer_key' => "my_tokens",
    'consumer_secret' => "my_tokens"
);

$hashtag = 'smartspend_eu';

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

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

The response is :

{"statuses":[],"search_metadata":{"completed_in":0.053,"max_id":1105019731759656961,"max_id_str":"1105019731759656961","query":"%23SMARTSPEND_EU","refresh_url":"?since_id=1105019731759656961&q=%23SMARTSPEND_EU&include_entities=1","count":15,"since_id":0,"since_id_str":"0"}}

What is the problem, and what can i do to fix it ?

  • 写回答

1条回答 默认 最新

  • duanchao9559 2019-03-27 13:28
    关注

    I finaly found what's wrong. My code was right from the begining. The problem is that it's impossible to get the tweets from more than 7 days ago. And no tweets has been written for my hashtag for the last 7 days.

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

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?