SlideShare ist ein Scribd-Unternehmen logo
1 von 9
Using                ’s API with PHP



    Katherine Lee | Internet Applications
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
• 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
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;
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
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
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
Future
• Better, more universal location standards for
  mobile use
• See only local tweets within a very small
  radius of wherever you happen to be
Thanks
Code based on William Abraham’s:
• Fire Eagle code -
  http://github.com/myelin/fireeagle-php-lib
• twitterlibphp -
  http://github.com/poseurtech/twitterlibphp

Weitere ähnliche Inhalte

Andere mochten auch

Thesis091009
Thesis091009Thesis091009
Thesis091009
klee4vp
 
autozone CodeofConductFY2008_English
autozone  CodeofConductFY2008_Englishautozone  CodeofConductFY2008_English
autozone CodeofConductFY2008_English
finance46
 
molson coors brewing COORS_AR2000
molson coors brewing  COORS_AR2000molson coors brewing  COORS_AR2000
molson coors brewing COORS_AR2000
finance46
 
Make everything realtime & collaborative - JS Summit 2014
Make everything realtime & collaborative - JS Summit 2014Make everything realtime & collaborative - JS Summit 2014
Make everything realtime & collaborative - JS Summit 2014
Joseph Gentle
 
MOLSONCOORS_AR2004_EN
MOLSONCOORS_AR2004_ENMOLSONCOORS_AR2004_EN
MOLSONCOORS_AR2004_EN
finance46
 
Презентация УТГ 2009
Презентация УТГ 2009Презентация УТГ 2009
Презентация УТГ 2009
Vadim Andreev
 
Kwyjibos
KwyjibosKwyjibos
Kwyjibos
klee4vp
 
omnicare annual reports 1998
omnicare annual reports 1998omnicare annual reports 1998
omnicare annual reports 1998
finance46
 
Thesis Midterm032610
Thesis Midterm032610Thesis Midterm032610
Thesis Midterm032610
klee4vp
 

Andere mochten auch (18)

1:World@Haverford
1:World@Haverford1:World@Haverford
1:World@Haverford
 
Thesis091009
Thesis091009Thesis091009
Thesis091009
 
Oof Epowerpoint
Oof EpowerpointOof Epowerpoint
Oof Epowerpoint
 
O azul
O azulO azul
O azul
 
Sears L
Sears LSears L
Sears L
 
autozone CodeofConductFY2008_English
autozone  CodeofConductFY2008_Englishautozone  CodeofConductFY2008_English
autozone CodeofConductFY2008_English
 
molson coors brewing COORS_AR2000
molson coors brewing  COORS_AR2000molson coors brewing  COORS_AR2000
molson coors brewing COORS_AR2000
 
Make everything realtime & collaborative - JS Summit 2014
Make everything realtime & collaborative - JS Summit 2014Make everything realtime & collaborative - JS Summit 2014
Make everything realtime & collaborative - JS Summit 2014
 
MOLSONCOORS_AR2004_EN
MOLSONCOORS_AR2004_ENMOLSONCOORS_AR2004_EN
MOLSONCOORS_AR2004_EN
 
Crowdfunding 7.27.13
Crowdfunding 7.27.13Crowdfunding 7.27.13
Crowdfunding 7.27.13
 
Creating a good architecture
Creating a good architectureCreating a good architecture
Creating a good architecture
 
Презентация УТГ 2009
Презентация УТГ 2009Презентация УТГ 2009
Презентация УТГ 2009
 
The Americas 2
The Americas 2The Americas 2
The Americas 2
 
Kwyjibos
KwyjibosKwyjibos
Kwyjibos
 
omnicare annual reports 1998
omnicare annual reports 1998omnicare annual reports 1998
omnicare annual reports 1998
 
Building A Goal Aligned Enterprise Public
Building A Goal Aligned Enterprise   PublicBuilding A Goal Aligned Enterprise   Public
Building A Goal Aligned Enterprise Public
 
Taking PHP to the next level
Taking PHP to the next levelTaking PHP to the next level
Taking PHP to the next level
 
Thesis Midterm032610
Thesis Midterm032610Thesis Midterm032610
Thesis Midterm032610
 

Ähnlich wie Locovore

OAuth Introduction
OAuth IntroductionOAuth Introduction
OAuth Introduction
h_marvin
 
BarCamp KL H20 Open Social Hackathon
BarCamp KL H20 Open Social HackathonBarCamp KL H20 Open Social Hackathon
BarCamp KL H20 Open Social Hackathon
marvin337
 
Windows Phone 8 - 13 Near Field Communcations and Bluetooth
Windows Phone 8 - 13 Near Field Communcations and BluetoothWindows Phone 8 - 13 Near Field Communcations and Bluetooth
Windows Phone 8 - 13 Near Field Communcations and Bluetooth
Oliver Scheer
 

Ähnlich wie Locovore (20)

Fire Eagle presentation for IIT Delhi Hack U event
Fire Eagle presentation for IIT Delhi Hack U eventFire Eagle presentation for IIT Delhi Hack U event
Fire Eagle presentation for IIT Delhi Hack U event
 
Yahoo! Geo Technologies-IITD
Yahoo! Geo Technologies-IITDYahoo! Geo Technologies-IITD
Yahoo! Geo Technologies-IITD
 
OAuth Introduction
OAuth IntroductionOAuth Introduction
OAuth Introduction
 
OAuth 2.0 and Mobile Devices: Is that a token in your phone in your pocket or...
OAuth 2.0 and Mobile Devices: Is that a token in your phone in your pocket or...OAuth 2.0 and Mobile Devices: Is that a token in your phone in your pocket or...
OAuth 2.0 and Mobile Devices: Is that a token in your phone in your pocket or...
 
PyConWeb - 2019 Auditing websites & apps for privacy leaks.
PyConWeb - 2019 Auditing websites & apps for privacy leaks.PyConWeb - 2019 Auditing websites & apps for privacy leaks.
PyConWeb - 2019 Auditing websites & apps for privacy leaks.
 
Securing RESTful APIs using OAuth 2 and OpenID Connect
Securing RESTful APIs using OAuth 2 and OpenID ConnectSecuring RESTful APIs using OAuth 2 and OpenID Connect
Securing RESTful APIs using OAuth 2 and OpenID Connect
 
Reaching out from ADF Mobile (ODTUG KScope 2014)
Reaching out from ADF Mobile (ODTUG KScope 2014)Reaching out from ADF Mobile (ODTUG KScope 2014)
Reaching out from ADF Mobile (ODTUG KScope 2014)
 
Swift meetup22june2015
Swift meetup22june2015Swift meetup22june2015
Swift meetup22june2015
 
Internet of things the salesforce lego machine cloud
Internet of things   the salesforce lego machine cloudInternet of things   the salesforce lego machine cloud
Internet of things the salesforce lego machine cloud
 
Zotero Visualisierungen
Zotero VisualisierungenZotero Visualisierungen
Zotero Visualisierungen
 
HTTP 프로토콜의 이해와 활용
HTTP 프로토콜의 이해와 활용HTTP 프로토콜의 이해와 활용
HTTP 프로토콜의 이해와 활용
 
MyATM
MyATMMyATM
MyATM
 
Goodle Developer Days Munich 2008 - Open Social Update
Goodle Developer Days Munich 2008 - Open Social UpdateGoodle Developer Days Munich 2008 - Open Social Update
Goodle Developer Days Munich 2008 - Open Social Update
 
BarCamp KL H20 Open Social Hackathon
BarCamp KL H20 Open Social HackathonBarCamp KL H20 Open Social Hackathon
BarCamp KL H20 Open Social Hackathon
 
Cloud Foundry API for Fun and Ops
Cloud Foundry API for Fun and OpsCloud Foundry API for Fun and Ops
Cloud Foundry API for Fun and Ops
 
Windows Phone 8 - 13 Near Field Communcations and Bluetooth
Windows Phone 8 - 13 Near Field Communcations and BluetoothWindows Phone 8 - 13 Near Field Communcations and Bluetooth
Windows Phone 8 - 13 Near Field Communcations and Bluetooth
 
Firesheep & HTTPS, Explained!
Firesheep & HTTPS, Explained!Firesheep & HTTPS, Explained!
Firesheep & HTTPS, Explained!
 
HTTP Basics Demo
HTTP Basics DemoHTTP Basics Demo
HTTP Basics Demo
 
What's happening here?
What's happening here?What's happening here?
What's happening here?
 
An Introduction to OAuth 2
An Introduction to OAuth 2An Introduction to OAuth 2
An Introduction to OAuth 2
 

Mehr von klee4vp

Mobile clinic breast_cancer_research_proposal_
Mobile clinic breast_cancer_research_proposal_Mobile clinic breast_cancer_research_proposal_
Mobile clinic breast_cancer_research_proposal_
klee4vp
 
Mobile clinic breast_cancer_research_proposal_
Mobile clinic breast_cancer_research_proposal_Mobile clinic breast_cancer_research_proposal_
Mobile clinic breast_cancer_research_proposal_
klee4vp
 
Mock thesisfinal042710
Mock thesisfinal042710Mock thesisfinal042710
Mock thesisfinal042710
klee4vp
 
Crystallized042210
Crystallized042210Crystallized042210
Crystallized042210
klee4vp
 
Crystallized040910
Crystallized040910Crystallized040910
Crystallized040910
klee4vp
 
Breast Cancer040710
Breast Cancer040710Breast Cancer040710
Breast Cancer040710
klee4vp
 
Nano Bio Art040201
Nano Bio Art040201Nano Bio Art040201
Nano Bio Art040201
klee4vp
 
Thesis Midterm032610
Thesis Midterm032610Thesis Midterm032610
Thesis Midterm032610
klee4vp
 
Thesis Midterm032610
Thesis Midterm032610Thesis Midterm032610
Thesis Midterm032610
klee4vp
 
Thesis Midterm030910
Thesis Midterm030910Thesis Midterm030910
Thesis Midterm030910
klee4vp
 
Breast Cancer030310
Breast Cancer030310Breast Cancer030310
Breast Cancer030310
klee4vp
 
Thesis012910
Thesis012910Thesis012910
Thesis012910
klee4vp
 
Thesis Brief012510
Thesis Brief012510Thesis Brief012510
Thesis Brief012510
klee4vp
 
Thesis Final120809
Thesis Final120809Thesis Final120809
Thesis Final120809
klee4vp
 
Thesis Final120309
Thesis Final120309Thesis Final120309
Thesis Final120309
klee4vp
 
Thesis Final120309
Thesis Final120309Thesis Final120309
Thesis Final120309
klee4vp
 
Thesis Update111909
Thesis Update111909Thesis Update111909
Thesis Update111909
klee4vp
 
Peer Review - MFADT thesis
Peer Review - MFADT thesisPeer Review - MFADT thesis
Peer Review - MFADT thesis
klee4vp
 
Thesis110309
Thesis110309Thesis110309
Thesis110309
klee4vp
 
Thesismidterm101309
Thesismidterm101309Thesismidterm101309
Thesismidterm101309
klee4vp
 

Mehr von klee4vp (20)

Mobile clinic breast_cancer_research_proposal_
Mobile clinic breast_cancer_research_proposal_Mobile clinic breast_cancer_research_proposal_
Mobile clinic breast_cancer_research_proposal_
 
Mobile clinic breast_cancer_research_proposal_
Mobile clinic breast_cancer_research_proposal_Mobile clinic breast_cancer_research_proposal_
Mobile clinic breast_cancer_research_proposal_
 
Mock thesisfinal042710
Mock thesisfinal042710Mock thesisfinal042710
Mock thesisfinal042710
 
Crystallized042210
Crystallized042210Crystallized042210
Crystallized042210
 
Crystallized040910
Crystallized040910Crystallized040910
Crystallized040910
 
Breast Cancer040710
Breast Cancer040710Breast Cancer040710
Breast Cancer040710
 
Nano Bio Art040201
Nano Bio Art040201Nano Bio Art040201
Nano Bio Art040201
 
Thesis Midterm032610
Thesis Midterm032610Thesis Midterm032610
Thesis Midterm032610
 
Thesis Midterm032610
Thesis Midterm032610Thesis Midterm032610
Thesis Midterm032610
 
Thesis Midterm030910
Thesis Midterm030910Thesis Midterm030910
Thesis Midterm030910
 
Breast Cancer030310
Breast Cancer030310Breast Cancer030310
Breast Cancer030310
 
Thesis012910
Thesis012910Thesis012910
Thesis012910
 
Thesis Brief012510
Thesis Brief012510Thesis Brief012510
Thesis Brief012510
 
Thesis Final120809
Thesis Final120809Thesis Final120809
Thesis Final120809
 
Thesis Final120309
Thesis Final120309Thesis Final120309
Thesis Final120309
 
Thesis Final120309
Thesis Final120309Thesis Final120309
Thesis Final120309
 
Thesis Update111909
Thesis Update111909Thesis Update111909
Thesis Update111909
 
Peer Review - MFADT thesis
Peer Review - MFADT thesisPeer Review - MFADT thesis
Peer Review - MFADT thesis
 
Thesis110309
Thesis110309Thesis110309
Thesis110309
 
Thesismidterm101309
Thesismidterm101309Thesismidterm101309
Thesismidterm101309
 

Kürzlich hochgeladen

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Kürzlich hochgeladen (20)

[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 

Locovore

  • 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