SlideShare a Scribd company logo
1 of 7
HOW TO GET DATA FROM
TWITTER?
Hani Nurrahmi
TWITTER API
 Twitter API is tools that provided by Twitter to
facilitate Twitter Developer to get data for their apps
 API (short for Application Programming Interface) is
a system that allows other applications to talk to an
application- receive information from it and send
information to it (iag.me).
 Twitter API can be developed in PHP, Pyton, Java, etc.
 This tutorial used PHP to be connected with Twitter
API (based on iag.me)
1. GET YOUR TWITTER API ACCESS!
 It is important step before you get data from Twitter
 How?
1. Go to https://dev.twitter.com/apps/new
2. Login with your Twitter account
3. There are some textfields that you have to fill in, i.e. Application Name,
Description of your apps, website, callback URL (you can leave this empty).
4. Accept the Term of Service and enter the captcha.
5. Click ‘Create your Twitter Application’
6. You can see the consumer key (CK) and consumer secret (CS) in Oauth settings.
7. Click ‘Create my access token’ to get your access token (AT) and access token
secret (ATS).
8. Now, you have anything you need to access Twitter API. CK, CS, AT, and ATS
should be copied in your apps (don’t forget to make it as secret since every
developer will have different code).
2. LET’S USE TWITTER API!
1. Get Twitter Wrapper tools to facilitate you to connect Twitter API. In this
tutorial, I used PHP Wrapper Script that available in
https://github.com/J7mbo/twitter-api-php/archive/master.zip . It works
for Twitter’s API v1.1. This wrapper require you to already installed cURL.
If you want to run your app in localhost, make sure the root certificates
installed for cURL is avaliable in your xampp settings.
2. After you’ve download the wrapper, unzip it. You will see file
‘TwitterAPIExchange.php’. This file contains of how our app can be
connected with Twitter API.
3. Make a PHP file to connect the wrapper and our app. Let’s name it as
‘myTweetApp.php’. Place this file in the same place with
‘TwitterAPIExchange.php’.
4. In our file ‘myTweetApp.php’, we need to use ‘TwitterAPIExchange.php’
so we add
5. We need to set our access tokens by adding it to the $settings array
$settings = array(
'oauth_access_token' => "YOUR_ACCESS_TOKEN",
'oauth_access_token_secret' => "YOUR_ACCESS_TOKEN_SECRET",
'consumer_key' => "YOUR_CONSUMER_KEY",
'consumer_secret' => "YOUR_CONSUMER_SECRET"
);
6. We need to give the PHP Twitter wrapper the URL so it can make the
correct API request for us.
$url = "https://api.twitter.com/1.1/statuses/user_timeline.json";
7. GET or POST?
$requestMethod = "GET";
8. What do we need?
$getfield = '?screen_name=iagdotme&count=20';
*for more details about any query that we can request, visit: https://dev.twitter.com
9. We need to make the call using the PHP Twitter Wrapper
$twitter = new TwitterAPIExchange($settings);
$string = json_decode($twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest(),$assoc = TRUE);
10.Make the output
foreach($string as $items)
{
$username = $items['user']['screen_name'];
$tweet = $items['text'];
echo "Username: ". $username."<br />";
echo "Tweet: ". $tweet."<br />";
}
11. Program Run!
TERIMA KASIH 

More Related Content

What's hot

Designing Your API
Designing Your APIDesigning Your API
Designing Your APIAlex Payne
 
Building TweetEngine
Building TweetEngineBuilding TweetEngine
Building TweetEngineikailan
 
Connecting your android application to cloud.
Connecting your android application to cloud.Connecting your android application to cloud.
Connecting your android application to cloud.Eng Chrispinus Onyancha
 
2b fmewt19 - fme server
2b   fmewt19 - fme server2b   fmewt19 - fme server
2b fmewt19 - fme serverConsortech
 
IFTTT: If This Then That
IFTTT: If This Then ThatIFTTT: If This Then That
IFTTT: If This Then ThatShashank Kapoor
 
Mule integration with linkedin
Mule integration with linkedinMule integration with linkedin
Mule integration with linkedinKhasim Saheb
 
Oracle IDM: Notifications
Oracle IDM: NotificationsOracle IDM: Notifications
Oracle IDM: NotificationsAbhishek Gupta
 
#Instagram API Get visibility you always wanted
#Instagram API   Get visibility you always wanted#Instagram API   Get visibility you always wanted
#Instagram API Get visibility you always wantedKetan Raval
 
How To Get Started And Use IFTTT
How To Get Started And Use IFTTTHow To Get Started And Use IFTTT
How To Get Started And Use IFTTTCa Milles
 

What's hot (13)

How to integrate bulk sms api in java
How to integrate bulk sms api in javaHow to integrate bulk sms api in java
How to integrate bulk sms api in java
 
Designing Your API
Designing Your APIDesigning Your API
Designing Your API
 
Building TweetEngine
Building TweetEngineBuilding TweetEngine
Building TweetEngine
 
Connecting your android application to cloud.
Connecting your android application to cloud.Connecting your android application to cloud.
Connecting your android application to cloud.
 
Bulk sms gateway integration in java
Bulk sms gateway integration in javaBulk sms gateway integration in java
Bulk sms gateway integration in java
 
Instalacion
InstalacionInstalacion
Instalacion
 
2b fmewt19 - fme server
2b   fmewt19 - fme server2b   fmewt19 - fme server
2b fmewt19 - fme server
 
IFTTT: If This Then That
IFTTT: If This Then ThatIFTTT: If This Then That
IFTTT: If This Then That
 
A Day in the Life of an Intranet: Eva Collins - HR Administrator
A Day in the Life of an Intranet: Eva Collins - HR AdministratorA Day in the Life of an Intranet: Eva Collins - HR Administrator
A Day in the Life of an Intranet: Eva Collins - HR Administrator
 
Mule integration with linkedin
Mule integration with linkedinMule integration with linkedin
Mule integration with linkedin
 
Oracle IDM: Notifications
Oracle IDM: NotificationsOracle IDM: Notifications
Oracle IDM: Notifications
 
#Instagram API Get visibility you always wanted
#Instagram API   Get visibility you always wanted#Instagram API   Get visibility you always wanted
#Instagram API Get visibility you always wanted
 
How To Get Started And Use IFTTT
How To Get Started And Use IFTTTHow To Get Started And Use IFTTT
How To Get Started And Use IFTTT
 

Similar to How to get data from twitter (by hnnrrhm)

Social media analysis in R using twitter API
Social media analysis in R using twitter API Social media analysis in R using twitter API
Social media analysis in R using twitter API Mohd Shadab Alam
 
Collect twitter data using python
Collect twitter data using pythonCollect twitter data using python
Collect twitter data using pythonKe Jiang
 
Collect twitter data using python
Collect twitter data using pythonCollect twitter data using python
Collect twitter data using pythonKe Jiang
 
Five steps to get tweets sent by a list of users
Five steps to get tweets sent by a list of usersFive steps to get tweets sent by a list of users
Five steps to get tweets sent by a list of usersWeiai Wayne Xu
 
Creating a mule project with raml and api
Creating a mule project with raml and apiCreating a mule project with raml and api
Creating a mule project with raml and apiBhargav Ranjit
 
6 Best Practices that Make a Great API .pdf
6 Best Practices that Make a Great API .pdf6 Best Practices that Make a Great API .pdf
6 Best Practices that Make a Great API .pdfExpert App Devs
 
Developing your personal Twitter web application in 60 minustes
Developing your personal Twitter web application in 60 minustesDeveloping your personal Twitter web application in 60 minustes
Developing your personal Twitter web application in 60 minustesMitesh Sanghvi
 
I Love APIs 2015: Advanced Crash Course in Apigee Edge Workshop
I Love APIs 2015: Advanced Crash Course in Apigee Edge Workshop I Love APIs 2015: Advanced Crash Course in Apigee Edge Workshop
I Love APIs 2015: Advanced Crash Course in Apigee Edge Workshop Apigee | Google Cloud
 
#tmeetup BirdHackers API 101
#tmeetup BirdHackers API 101#tmeetup BirdHackers API 101
#tmeetup BirdHackers API 101jstrellner
 
How to Implement Token Authentication Using the Django REST Framework
How to Implement Token Authentication Using the Django REST FrameworkHow to Implement Token Authentication Using the Django REST Framework
How to Implement Token Authentication Using the Django REST FrameworkKaty Slemon
 
Designing CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIsDesigning CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIsNeil Crookes
 
Mz twitter-1.1-sdl
Mz twitter-1.1-sdlMz twitter-1.1-sdl
Mz twitter-1.1-sdlAngus Fox
 
Twitter Update for Social Developers London - March 2013
Twitter Update for Social Developers London - March 2013Twitter Update for Social Developers London - March 2013
Twitter Update for Social Developers London - March 2013Angus Fox
 

Similar to How to get data from twitter (by hnnrrhm) (20)

Social media analysis in R using twitter API
Social media analysis in R using twitter API Social media analysis in R using twitter API
Social media analysis in R using twitter API
 
Collect twitter data using python
Collect twitter data using pythonCollect twitter data using python
Collect twitter data using python
 
Collect twitter data using python
Collect twitter data using pythonCollect twitter data using python
Collect twitter data using python
 
Five steps to get tweets sent by a list of users
Five steps to get tweets sent by a list of usersFive steps to get tweets sent by a list of users
Five steps to get tweets sent by a list of users
 
başlık
başlıkbaşlık
başlık
 
Creating a mule project with raml and api
Creating a mule project with raml and apiCreating a mule project with raml and api
Creating a mule project with raml and api
 
6 Best Practices that Make a Great API .pdf
6 Best Practices that Make a Great API .pdf6 Best Practices that Make a Great API .pdf
6 Best Practices that Make a Great API .pdf
 
Developing your personal Twitter web application in 60 minustes
Developing your personal Twitter web application in 60 minustesDeveloping your personal Twitter web application in 60 minustes
Developing your personal Twitter web application in 60 minustes
 
I Love APIs 2015: Advanced Crash Course in Apigee Edge Workshop
I Love APIs 2015: Advanced Crash Course in Apigee Edge Workshop I Love APIs 2015: Advanced Crash Course in Apigee Edge Workshop
I Love APIs 2015: Advanced Crash Course in Apigee Edge Workshop
 
#tmeetup BirdHackers API 101
#tmeetup BirdHackers API 101#tmeetup BirdHackers API 101
#tmeetup BirdHackers API 101
 
Twitter4R OAuth
Twitter4R OAuthTwitter4R OAuth
Twitter4R OAuth
 
How to Implement Token Authentication Using the Django REST Framework
How to Implement Token Authentication Using the Django REST FrameworkHow to Implement Token Authentication Using the Django REST Framework
How to Implement Token Authentication Using the Django REST Framework
 
Api Testing.pdf
Api Testing.pdfApi Testing.pdf
Api Testing.pdf
 
Designing CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIsDesigning CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIs
 
Api manager preconference
Api manager preconferenceApi manager preconference
Api manager preconference
 
Twitter api
Twitter apiTwitter api
Twitter api
 
R project(Analyze Twitter with R)
R project(Analyze Twitter with R)R project(Analyze Twitter with R)
R project(Analyze Twitter with R)
 
Mz twitter-1.1-sdl
Mz twitter-1.1-sdlMz twitter-1.1-sdl
Mz twitter-1.1-sdl
 
AIR & API
AIR & APIAIR & API
AIR & API
 
Twitter Update for Social Developers London - March 2013
Twitter Update for Social Developers London - March 2013Twitter Update for Social Developers London - March 2013
Twitter Update for Social Developers London - March 2013
 

Recently uploaded

This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxPooja Bhuva
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsNbelano25
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Pooja Bhuva
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsSandeep D Chaudhary
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 

Recently uploaded (20)

This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 

How to get data from twitter (by hnnrrhm)

  • 1. HOW TO GET DATA FROM TWITTER? Hani Nurrahmi
  • 2. TWITTER API  Twitter API is tools that provided by Twitter to facilitate Twitter Developer to get data for their apps  API (short for Application Programming Interface) is a system that allows other applications to talk to an application- receive information from it and send information to it (iag.me).  Twitter API can be developed in PHP, Pyton, Java, etc.  This tutorial used PHP to be connected with Twitter API (based on iag.me)
  • 3. 1. GET YOUR TWITTER API ACCESS!  It is important step before you get data from Twitter  How? 1. Go to https://dev.twitter.com/apps/new 2. Login with your Twitter account 3. There are some textfields that you have to fill in, i.e. Application Name, Description of your apps, website, callback URL (you can leave this empty). 4. Accept the Term of Service and enter the captcha. 5. Click ‘Create your Twitter Application’ 6. You can see the consumer key (CK) and consumer secret (CS) in Oauth settings. 7. Click ‘Create my access token’ to get your access token (AT) and access token secret (ATS). 8. Now, you have anything you need to access Twitter API. CK, CS, AT, and ATS should be copied in your apps (don’t forget to make it as secret since every developer will have different code).
  • 4. 2. LET’S USE TWITTER API! 1. Get Twitter Wrapper tools to facilitate you to connect Twitter API. In this tutorial, I used PHP Wrapper Script that available in https://github.com/J7mbo/twitter-api-php/archive/master.zip . It works for Twitter’s API v1.1. This wrapper require you to already installed cURL. If you want to run your app in localhost, make sure the root certificates installed for cURL is avaliable in your xampp settings. 2. After you’ve download the wrapper, unzip it. You will see file ‘TwitterAPIExchange.php’. This file contains of how our app can be connected with Twitter API. 3. Make a PHP file to connect the wrapper and our app. Let’s name it as ‘myTweetApp.php’. Place this file in the same place with ‘TwitterAPIExchange.php’. 4. In our file ‘myTweetApp.php’, we need to use ‘TwitterAPIExchange.php’ so we add
  • 5. 5. We need to set our access tokens by adding it to the $settings array $settings = array( 'oauth_access_token' => "YOUR_ACCESS_TOKEN", 'oauth_access_token_secret' => "YOUR_ACCESS_TOKEN_SECRET", 'consumer_key' => "YOUR_CONSUMER_KEY", 'consumer_secret' => "YOUR_CONSUMER_SECRET" ); 6. We need to give the PHP Twitter wrapper the URL so it can make the correct API request for us. $url = "https://api.twitter.com/1.1/statuses/user_timeline.json"; 7. GET or POST? $requestMethod = "GET"; 8. What do we need? $getfield = '?screen_name=iagdotme&count=20'; *for more details about any query that we can request, visit: https://dev.twitter.com
  • 6. 9. We need to make the call using the PHP Twitter Wrapper $twitter = new TwitterAPIExchange($settings); $string = json_decode($twitter->setGetfield($getfield) ->buildOauth($url, $requestMethod) ->performRequest(),$assoc = TRUE); 10.Make the output foreach($string as $items) { $username = $items['user']['screen_name']; $tweet = $items['text']; echo "Username: ". $username."<br />"; echo "Tweet: ". $tweet."<br />"; } 11. Program Run!