我正在使用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"
}
}
有没有人知道为什么这可能是一个不一致的问题,如果有更好的解决办法吗?
答案 0 :(得分:0)
进行一些研究我发现twitter API只能回溯6-9天的推文,因此如果你想回顾一下时间,你需要使用until
参数。
查看最佳实践部分https://dev.twitter.com/docs/using-search上的文档。