Created
June 10, 2012 22:53
-
-
Save MikeRogers0/2907584 to your computer and use it in GitHub Desktop.
Displaying Recent Stumbles (From StumbleUpon)
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 3rd April 2009 by Mike Rogers (http://www.fullondesign.co.uk/). | |
/* | |
function – recent_stumbles(string $username [, string $type= NULL [, int $limit = 5]]) | |
$username – The stumbleupon username, such as rogem002 | |
$type – Default: NULL – What you want to limit your rss to show. Can be NULL, blog, comments, favorites or reviews | |
$limit – Default: 5 – how many tweets you wish to show, must be numeric. | |
*/ | |
function recent_stumbles($username, $type=NULL, $limit=5){ | |
if(!is_numeric($limit)){$limit = 5;} | |
if($type !== NULL && $type !== 'blog' && $type !== 'comments' && $type !== 'favorites' && $type !== 'reviews'){$type = NULL;} | |
$xml = simplexml_load_file('http://rss.stumbleupon.com/user/'.urlencode($username).'/'.$type); | |
$items_count= count($xml->channel->item); | |
if($items_count < $limit){$limit = $items_count;} | |
$i = 0; | |
$return .= '<ul>'; | |
while($i < $limit){ | |
$return .= ' | |
<li title="'.$xml->channel->item[$i]->title.'"><!– '.$xml->channel->item[$i]->pubDate.' –> | |
<a href="'.$xml->channel->item[$i]->link.'" title="'.$xml->channel->item[$i]->title.'"><img src="'.$xml->channel->item[$i]->enclosure["url"].'" alt="'.$xml->channel->item[$i]->title.'" border="0" /> | |
'.$xml->channel->item[$i]->title.'</a></li> | |
'; | |
$i++; | |
} | |
$return .= '</ul>'; | |
return $return; | |
} | |
echo recent_stumbles('Rogem002', 'favorites', 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