public function processResponse(array $resp) { $noNew = true; foreach ($resp as $tweetData) { if (!($savedTweet = DataObject::get_one('Tweet', "TweetID='" . $tweetData->id_str . "'"))) { if (!($pubTweet = DataObject::get_one('PublicationTweet', "TweetID='" . $tweetData->id_str . "'"))) { // push output echo "Adding Tweet " . $tweetData->id_str . "<br />\n"; flush(); @ob_flush(); // create the tweet data object $tweet = new Tweet(); $tweet->updateFromTweet($tweetData); $tweet->write(); if (!$tweet->doPublish()) { die('Failed to Publish ' . $tweet->Title); } // set no new flag $noNew = false; } else { // push output echo "Tweet " . $tweetData->id_str . " came from the website<br />\n"; flush(); @ob_flush(); } } else { // this should only happen during initial population because we should have only got in tweets that are newer than x // push output echo "Already added Tweet " . $tweetData->id_str . "<br />\n"; flush(); @ob_flush(); } } return $noNew; }