locovore

9
Katherine Lee | Internet Applications Using ’s API with PHP

Upload: klee4vp

Post on 28-Jan-2015

103 views

Category:

Technology


1 download

DESCRIPTION

round 2

TRANSCRIPT

Page 1: Locovore

Katherine Lee | Internet Applications

Using ’s API with PHP

Page 2: Locovore

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

Page 3: Locovore

• 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

Page 4: Locovore

cURL: How the API communicates with PHP

function http($url, $post_data = null) {/*{{{*/ $ch = curl_init(); if (defined("CURL_CA_BUNDLE_PATH")) 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;

Page 5: Locovore

How Twitter OAuth works• You register your application with Twitter, specifying a callback URL• Twitter gives you:

1. Consumer key2. Consumer secret3. Request token URL4. Access token URL5. 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

Page 6: Locovore

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

Page 7: Locovore

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

Page 8: Locovore

Future

• Better, more universal location standards for mobile use

• See only local tweets within a very small radius of wherever you happen to be

Page 9: Locovore

Thanks

Code based on William Abraham’s:• Fire Eagle code -

http://github.com/myelin/fireeagle-php-lib• twitterlibphp -

http://github.com/poseurtech/twitterlibphp