Trying to return all tweets in the last 24hours from a user, but not sure how to do it, this is the code i have so far and that is just to get the last 5 tweet's, not sure how to do the next step...
Thx Matt.
<?php
$username = "MelbournePollen";
$count = 5;
$tweet=json_decode(file_get_contents("http://api.twitter.com/1/statuses/user_timeline/".$username.".json?count=".$count."" ));
for ($i=1; $i <= $count; $i++){
//Assign feed to $feed
$feed = $tweet[($i-1)]->text;
echo date("M \- j",strtotime($tweet[($i-1)]->created_at)). " -- " .$feed. "</br>";
}?>
The following code should steer you in the right direction, building on your logic (my code is untested):
<?php
$username = "MelbournePollen";
$count = 5;
$tweet=json_decode(file_get_contents("http://api.twitter.com/1/statuses/user_timeline/".$username.".json?count=".$count."" ));
$tweets = array();
for ($i=1; $i <= $count; $i++){
//Assign feed to $feed
$feed = $tweet[($i-1)]->text;
$time_between = time() - strtotime($tweet[($i-1)]->created_at);
$twenty4hours = 60 * 60 * 24;
if($time_between <= $twenty4hours)
{
$tweets[] = $tweet;
}
}
//Use $tweets array as needed
?>
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.