Sunday, June 21, 2009

Embed Iran Tweet Google Maps Mashup in your website

Here's the code which you can embed in your webpage to see tweets related to ongoing Iran Election protests from Iran, Eurpoe and United States.


<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://www.mibazaar.com/irantweets.html"></iframe><br /><small><a href="http://www.mibazaar.com/irantweets.html" style="color:#0000FF;text-align:left">View Larger Map</a></small>

Labels: , ,

6 Comments:

At 10:06 AM, Blogger William said...

Hi, just wondering how you are able to get the location of the tweet? I want to display tweets on a map but I don't know how to get the long. and lat. of a tweet.

 
At 10:11 AM, Blogger Virender Ajmani said...

William! Twitter returns the location and that location information is fed into Google's Geocoding API which in turn returns Latitude and Longitude. You might want to first check out: http://apiwiki.twitter.com/

Regards,
Virender

 
At 10:19 AM, Blogger William said...

$curl = curl_init();
// $fp = fopen("somefile.txt", "w");
curl_setopt ($curl, CURLOPT_URL, "http://search.twitter.com/search.atom?q=Japan");
curl_setopt($curl, CURLOPT_FILE, $fp);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec ($curl);

$xml = new SimpleXMLElement($result);

foreach ($xml-*entry AS $resultset) {

echo "*p*$resultset-*title (*a href='".$resultset-*author-*uri."'*".$resultset-*author-*name."*/a*)*/p*";

}

// fwrite($fp, $result);
// fclose($fp);




Thanks,
William

 
At 12:41 PM, Blogger Virender Ajmani said...

For query like that your url should be like this:
http://search.twitter.com/search.atom?q=japan&geocode=40.757929%2C-73.985506%2C25km

i have tried max radius till 1500 miles. but you have got to provide the geocode parameter in order for the twitter search to return locations. In the above case it returns all queries as it relates to "Japan" within 25km of New York City. instead of km you can also use mi for miles

 
At 10:19 AM, Blogger andrew ford lyons said...

Would be great if the annoying ad wasn't there obscuring the Tweets. Plus, it defaults to a view on Palestine instead of Iran before the first Tweet loads.

 
At 10:26 AM, Blogger Virender Ajmani said...

No problems. Will change the default map view and will take care of the ad interference.

thanks,
Virender

 

Post a Comment

<< Home