Reputation: 855
I was experimenting on the Twitter API today in PHP. I imported the twitteroauth library and made the calls to search a simple hashtag. The problem is, if I browse and search for the same hashtag in twitter itself, there are many such tweets but the api returns me only 4 tweets. If I change the hashtag to something else, it returns the full list. What am I doing wrong? Below is the code:
$connection = new TwitterOAuth($consumerkey, $consumersecret, $access_token, $access_token_secret);
$content = $connection->get("search/tweets", ["q" => "#cutserv"]);
foreach($content->statuses as $tweet)
{
echo "Tweet: ".$tweet->text;
echo "<br/>";
echo "Time: ".$tweet->created_at;
echo "<br/><hr/>";
}
The response is always this:
Tweet: You need high-performers for great #cutserv
Time: Fri Sep 09 09:10:21 +0000 2016
Tweet: I join 62 other experts to discuss #cutserv improvement w/ @onereach.
Time: Wed Sep 07 23:01:28 +0000 2016
Tweet: “Immerse yourself in the customer's world and get to know their struggles and triumphs inside out.” ― Dane Brookes #quote #cutserv
Time: Mon Sep 05 13:14:53 +0000 2016
Tweet: You need high-performers for great #cutserv
Time: Fri Sep 02 09:10:23 +0000 2016
Upvotes: 0
Views: 162
Reputation: 14334
From the Documentation
The Twitter Search API searches against a sampling of recent Tweets published in the past 7 days.
Emphasis added. The API will only let you search through the last week of Tweets. Using the website you can search everything.
Upvotes: 1