/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php /* USE <?php echo $twitterFeed; ?> TO OUTPUT THE FEED */ /* YOUR TWITTER USER INFORMATION */ $twitID = 'booshstudios'; /* TWITTER X TIME AGO CONVERSION */ function niceTime($time) { if ($delta < 60) { return 'less than a minute ago'; } else if ($delta < 120) { return 'about a minute ago'; } else if ($delta < (45 * 60)) { } else if ($delta < (90 * 60)) { return 'about an hour ago'; } else if ($delta < (24 * 60 * 60)) { } else if ($delta < (48 * 60 * 60)) { return '1 day ago.'; } else { } } /* GET TWITTER FEED FUNCTION */ function getTwitterStatus($twitterUser, $howMany = 1) { /* ERROR HANDLING - DEFAULT IS SET AT 0 (OFF) */ $url = sprintf("http://api.twitter.com/1/statuses/user_timeline/%s.xml?count=%d", $twitterUser, $howMany); if (!$feed_data_get) { // IF THE FEED IS UNAVAILABLE OUTPUT ERROR echo '<center>Feed Unavailable, Try Again Later.</center>'; } else { // IF IT IS AVAILABLE OUTPUT FEED $parsed = new SimpleXMLElement($feed_data_get); foreach($parsed->status as $status) { $status->text); } return $tweets; } } /* TWITTER OUTPUT - Don't touch unless you know what you're doing. */ $status = getTwitterStatus($twitID); $twitterFeed = ($status[0]['message']); ?>