Skip to content

Instantly share code, notes, and snippets.

@victorcosta12
Forked from wescleymatos/gasolina_rn.php
Created March 6, 2013 17:41
Show Gist options
  • Save victorcosta12/5101318 to your computer and use it in GitHub Desktop.
Save victorcosta12/5101318 to your computer and use it in GitHub Desktop.
<?php
$search = "http://search.twitter.com/search.atom?q=gasolina&rpp=50&geocode=-5.794478%2C-35.210953%2C100km";
$tw = curl_init();
curl_setopt($tw, CURLOPT_URL, $search);
curl_setopt($tw, CURLOPT_RETURNTRANSFER, TRUE);
$twi = curl_exec($tw);
$search_res = new SimpleXMLElement($twi);
foreach ($search_res->entry as $twit1) {
$description = $twit1->content;
$description = preg_replace("#(^|[\n ])@([^ \"\t\n\r<]*)#ise", "'\\1<a href=\"http://www.twitter.com/\\2\" >@\\2</a>'", $description);
$description = preg_replace("#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t<]*)#ise", "'\\1<a href=\"\\2\" >\\2</a>'", $description);
$description = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r<]*)#ise", "'\\1<a href=\"http://\\2\" >\\2</a>'", $description);
$retweet = strip_tags($description);
echo "<div class='user'><a href=\"",$twit1->author->uri,"\" target=\"_blank\"><img border=\"0\" width=\"48\" class=\"twitter_thumb\" src=\"",$twit1->link[1]->attributes()->href,"\" title=\"", $twit1->author->name, "\" /></a>\n";
echo "<div class='text'>".$description."<div class='description'>From: ", $twit1->author->name," <a href='http://twitter.com/home?status=RT: ".$retweet."' target='_blank'>Retweet!</a></div><strong>".$datediff."</strong></div><div class='clear'></div></div>";
}
curl_close($tw);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment