I tried using the Twitter API and I want to count how many tweets are being tweeted in the last 24 hours containing a special hashtag.
I couldnt really find a way to do so? It seems to be limited to 100?
I need to get the amount of tweets in the last 24 hours in order to setup some stats on my website.
Current code:
<?php
ini_set('display_errors', 1);
require_once('TwitterAPIClass/TwitterAPIExchange.php');
/** Set access tokens here - see: https://dev.twitter.com/apps/ **/
$settings = array(
'oauth_access_token' => "XXXX",
'oauth_access_token_secret' => "YYYY",
'consumer_key' => "XXXX",
'consumer_secret' => "YYYY"
);
/** Perform a GET request and echo the response **/
/** Note: Set the GET field BEFORE calling buildOauth(); **/
$url = 'https://stream.twitter.com/1.1/statuses/filter.json';
$getfield = '?track=%23beer';
$requestMethod = 'GET';
$twitter = new TwitterAPIExchange($settings);
$twitter_data = json_decode($twitter->setGetfield($getfield)->buildOauth($url, $requestMethod)->performRequest(), true);
foreach($twitter_data['statuses'] as $tweets) {
echo $tweets['created_at'] . '<br>';
}
?>