Uploaded on

round 2

round 2

More in: Technology , Design
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
487
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
1
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Using ’s API with PHP Katherine Lee | Internet Applications
  • 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. • 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. 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. 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. 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. 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. 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. Thanks Code based on William Abraham’s: • Fire Eagle code - http://github.com/myelin/fireeagle-php-lib • twitterlibphp - http://github.com/poseurtech/twitterlibphp