Created
December 22, 2010 17:03
-
-
Save HansF/751762 to your computer and use it in GitHub Desktop.
Input from macs.php, output linked profile images. example: http://fanatic.be/twit/
This file contains 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 | |
$url = "http://0x20.be/pam/macs"; | |
if ($fp = fopen($url, 'r')) { | |
$output = ''; | |
while ($line = fgets($fp, 1024)) { | |
$content .= $line; | |
} | |
$Twitternames = parseContent ($content); | |
if (is_array($Twitternames)) $output = generateHtml ($Twitternames); | |
echo $output; | |
}else{ | |
echo "FAIL"; | |
} | |
function parseContent ($content){ | |
$twitternames = TwitterNamesFromString($content); | |
return $twitternames; | |
} | |
function TwitterNamesFromString($content){ | |
$content = str_replace('"','',trim ($content, '[]')); | |
$macs = explode(",",$content); | |
while ($mac = array_pop($macs)){ | |
if (stristr($mac,"@")){ | |
$out[] = trim (trim ($mac, '"')," "); | |
} | |
} | |
return $out; | |
} | |
function generateHtml ($twitternames){ | |
$output = ""; | |
foreach ($twitternames as $twittername){ | |
$xml ="http://api.twitter.com/1/users/show/$twittername.xml"; | |
$xml = simplexml_load_file($xml) or die("feed not loading"); | |
$imgurl = $xml->profile_image_url ; | |
$name = $xml->name ; | |
$screen_name = $xml->screen_name ; | |
$output .= "<a href ='http://twitter.com/$screen_name' title='$name'><img src='$imgurl' border='0'></a>"; | |
} | |
return $output; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment