Created
January 10, 2012 12:30
-
-
Save wescleymatos/1588809 to your computer and use it in GitHub Desktop.
Este projeto é uma implementação da api ed search do twitter. Sua funcionalidade inicial é pegar os últimos 50 twitts com menções a palavra gasolina na cidade de nata/rn.
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 | |
$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