I'm using the Twitter Search API v1.1 to simply search by hashtag #monstercareers. This bit of code works for other hashtags, but will not work for this particular one. I know this API is slightly different from the one Twitter actually uses (which makes it difficult to test), but if you search #monstercareers on Twitter.com it works fine.
<?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();
?>
Here is the empty response I get with the above code:
{
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"
}
}
Does anyone have any idea on why this might be an inconsistency, and if there's a better way around this?
Doing some research I have found that the twitter API only looks back up to 6-9 days of tweets, so in the case you might want to look back on time, you need to use the until
param.
Checkout the documentation on https://dev.twitter.com/docs/using-search on the Best Practices Section.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.