How will I create a function to take an array of tweets from twitter using TwitterOAuth by Abraham Williams, to be able to compare the array of tweets e.g
Tweet A With Tweet B With Tweet C and so on?
require_once('Twitter/twitteroauth/twitteroauth.php');
require_once('Twitter/Twitter_Config.php');
$userTimeline = $connection->get('statuses/user_ti');
function createAnArrayofTweetTimes($timeline)
{
$tweetTimes = array();
foreach ($timeline as $tweet) {
$tweettext = strtolower($tweet->text);
if (stristr($tweettext, '#edgarsclub')) {
array_push($tweetTimes, $tweet->created_at);
array_push($tweetTimes, 1);
echo $tweet->created_at;
}
}
return $tweetTimes;
}
I want to take this value which will be an array
$tweetTimes = $createAnArrayofTweetTimes($usertimeline)
And compare each tweet with the next one using the succeeding function.
function tweetTime($x, $y)
{
//THIS FUNCITON WILL COMPARE TWEETS WITH ONE ANOTHER
//TAKE PRECEDING TWEET AND COMPARE WITH SUCCEEDING TWEET
//IF LESS THEN 24 RETURN FALSE
$currentTime = strtotime($currentTime);
$tweetTime = strtotime($tweetTime);
$timeInSeconds = $currentTime - $tweetTime;
if ($timeInSeconds > 84600) {
return true;
} else {
return false;
}
}
See below a suggested approach:
I hope this helps. If not please post again. Good luck!