Quantcast
Channel: ProgrammableWeb - Location
Viewing all articles
Browse latest Browse all 1090

How to Use Twitter API and PHP to Locate Eyewitnesses

$
0
0
Primary Target Audience: 
Primary Channel: 
Primary category: 
Related Companies: 
Headline on Actual Article : 
Using Social Media to Locate Eyewitnesses: The Twitter API
Related Framework: 
Yii PHP Framework by Yii

Geotagging is the process of embedding latitude, longitude, and even altitude coordinates in some type of media, such as a photo, video or promotional offer. Many people don’t realise it, but modern mobile phones are constantly recording our movements and making that information available to network providers, and sometimes even third-parties willing to pay for the data.

As the second installment in a two-part Tuts+ series on harnessing location data from social media, Jeff Reifman discussed using the Twitter API to find eyewitnesses to a public event. In this case it was President Obama’s speech at the Edmund Pettus Bridge in Selma back in March. The author begins by registering a developer application with Twitter using the relevant access tokens for the account.

Reifman then sets up an Active Record migration to store the tweets received from the API, before using Google Maps to get the GPS coordinates of the bridge. The Twitter API’s limitations to search only by date within the last 7 days means that the search does require some refinements. This application makes requests to Twitter at the given coordinates on the specified date, with Reifman recording only those tweets that occurred during his desired time range.

Twitter returns up to 100 tweets per API call, so this application begins at the end of the specified day, working backwards in time to request additional records that are earlier than the previous batch. This process is looped until fewer than 100 records are returned or when tweets are earlier than the specified date range.

With all of the results returned, followers can browse the recorded tweets to perform the intended task, whatever that may be. This “Eyewitness App” is built in the Yii framework for PHP. All of the code is provided, as well as links to the complete code repository on GitHub.

Related APIs: 
Twitter
Summary: 
Since our mobile devices collect location data, Jeff Reifman guides followers through building an application to locate eyewitnesses to an important event using Twitter API.
Secondary category: 
Related Languages: 
URL To Article: 
http://code.tutsplus.com/tutorials/using-social-media-to-locate-eyewitnesses-the-twitter-api--cms-23580
Name of Host Site: 
Tuts+
URL To Home Page of Host Site: 
http://tutsplus.com/

Viewing all articles
Browse latest Browse all 1090

Trending Articles