Created
June 10, 2012 22:55
-
-
Save MikeRogers0/2907593 to your computer and use it in GitHub Desktop.
Displaying Recent Tweets via Twitter’s RSS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php # File created on 1st April 2009 by Mike Rogers (http://www.fullondesign.co.uk/). | |
/* | |
function – recent_tweets(string $username [, int $limit = 5]) | |
$username – Your twitter username, such as rogem002 | |
$limit – Default: 5 – how many tweets you wish to show, must be numeric. | |
*/ | |
function recent_tweets($username, $limit=5){ | |
if(!is_numeric($limit)){$limit = 5;} | |
$xml = simplexml_load_file('http://search.twitter.com/search.atom?q=from%3A'.urlencode($username)); | |
$items_count= count($xml->entry); | |
if($items_count < $limit){$limit = $items_count;} | |
$i = 0; | |
$return .= ' | |
<ul>'; | |
while($i < $limit){ | |
$return .= ' | |
<li title="'.$xml->entry[$i]->title.'"><!– '.$xml->entry[$i]->published.' –>'.$xml->entry[$i]->content.'</li> | |
'; | |
$i++; | |
} | |
$return .= '</ul> | |
'; | |
return $return; | |
} | |
echo recent_tweets('rogem002', 5); | |
/* | |
You are free to share, modify and use this code for commercial uses. Please give a link back (to http://www.fullondesign.co.uk/ ) if you can, but you don't have you. | |
*/ | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment