Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Locovore

round 2

  • Login to see the comments

  • Be the first to like this

Locovore

  1. 1. Using ’s API with PHP Katherine Lee | Internet Applications
  2. 2. beta Concept: using Twitter’s API and a PHP site to retrieve and store mobile location and message in a database On my way to the library, where my wildest dreams are going to come true today
  3. 3. • OAuth is an authentication protocol through which a user may allow an application to perform some action on their behalf without sharing their password • The important thing is that it’s a standardized way of granting secure API access to user accounts
  4. 4. cURL: How the API communicates with PHP function http($url, $post_data = null) {/*{{{*/ $ch = curl_init(); if (defined(quot;CURL_CA_BUNDLE_PATHquot;)) curl_setopt($ch, CURLOPT_CAINFO, CURL_CA_BUNDLE_PATH); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); ////////////////////////////////////////////////// ///// Set to 1 to verify Twitter's SSL Cert ////// ////////////////////////////////////////////////// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); if (isset($post_data)) { curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); } $response = curl_exec($ch); $this->http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE); $this->last_api_call = $url; curl_close ($ch); return $response;
  5. 5. How Twitter OAuth works • You register your application with Twitter, specifying a callback URL • Twitter gives you: 1. Consumer key 2. Consumer secret 3. Request token URL 4. Access token URL 5. Authorize URL • Consumer key+secret initiate a conversation with Twitter • If the key+secret are validated by Twitter, Twitter’s request token allows you to send the user to an authorize URL • If the user grants your application permission, Twitter sends the user to your callback URL
  6. 6. Info I can pull on the User • Full name • Twitter username • Location (longitude/latitude only for GPS or iPhone enabled devices) • Photo icon • Date joined Twitter network • Date/Time/Message in last tweet Locovore demo
  7. 7. Issues • Lack of standardization in mobile location capability in devices • Twitterific (and apps like it) are only for iPhone or GPS- supporting devices • Google Latitude only supported by: – Android-powered devices – Most color Blackberry devices – Most Windows Mobile 5.0+ devices – Most Symbian S60 devices • Too bad if you don’t have GPS – your Google MyLocation will be inaccurate and is only supported on some Motorola and Sony Erickson devices outside of those devices supported by Google Latitude
  8. 8. Future • Better, more universal location standards for mobile use • See only local tweets within a very small radius of wherever you happen to be
  9. 9. Thanks Code based on William Abraham’s: • Fire Eagle code - http://github.com/myelin/fireeagle-php-lib • twitterlibphp - http://github.com/poseurtech/twitterlibphp

×