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.

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

报告相同问题?

悬赏问题

  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥15 键盘指令混乱情况下的启动盘系统重装
  • ¥40 复杂的限制性的商函数处理