Ver Mensaje Individual
  #1 (permalink)  
Antiguo 16/12/2012, 16:43
alvarols
 
Fecha de Ingreso: diciembre-2008
Mensajes: 738
Antigüedad: 15 años, 5 meses
Puntos: 15
Obtener geolocalización de Tweets

Estoy aprendiendo a usar la API de Twitter, ya logré extraer los últimos tweets de acuerdo a un hashtag.

Ahora mi duda es como puedo saber cual es la geolocalización de esos tweets. Es decir, saber de donde vienen para poder ponerlos en un mapa.

Los tweets los extraigo de un RSS de Twitter con PHP de esta manera:

Código PHP:
Ver original
  1. <?php
  2.  
  3. function getTweets() {
  4.  
  5.     $url = 'http://search.twitter.com/search.atom?q=desarrollo' ;
  6.     $ch = curl_init($url);
  7.     curl_setopt ($ch, CURLOPT_RETURNTRANSFER, TRUE);
  8.     $xml = curl_exec ($ch);
  9.     curl_close ($ch);
  10.  
  11.     //If you want to see the response from Twitter, uncomment this next part out:
  12.     //echo "<p>Response:</p>";
  13.     //echo "<pre>".htmlspecialchars($xml)."</pre>";
  14.  
  15.     $affected = 0;
  16.     $twelement = new SimpleXMLElement($xml);
  17.     foreach ($twelement->entry as $entry) {
  18.         $text = trim($entry->title);
  19.         $author = trim($entry->author->name);
  20.         $time = strtotime($entry->published);
  21.         $id = $entry->id;
  22.         echo "<p>Tweet from ".$author.": <strong>".$text."</strong>  <em>Posted ".date('n/j/y g:i a',$time)."</em></p>";
  23.     }
  24.  
  25.     return true ;
  26. }
  27.  
  28.  
  29. ?>

<?php
getTweets();
?>

Gracias