Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get location of Tweets with Twitter search API

The statuses/user_timeline part of the Twitter API returns geolocation data as "place" along with each Tweet. The search API, on the other hand, does not return this location data (as far as I can tell). Is there a way to get location data with the search API?

like image 242
Matt Fordham Avatar asked Nov 18 '11 21:11

Matt Fordham


2 Answers

There is a geo field in each result of the search resource (see the example in the documentation), which is a form of geolocation, but is not the exact same thing as the place field in the statuses/user_timeline.

Alternatively you can make another request using the id of the result through the statuses/show/:id resource (see documentation) which returns both the geo and place fields, but that would mean making one more request per result.

like image 102
João Pesce Avatar answered Oct 09 '22 11:10

João Pesce


Matt asked this question directly to Twitter and got a response, and the dev who answered pointed out that the JSON format does include a 'geo' attribute.

like image 34
alxndr Avatar answered Oct 09 '22 09:10

alxndr