Friday, August 2, 2013

How to make request with twitter 1.1 API

If you have ever got to tasked for working with twitter API here is an start up tutorial for you with twitter latest 1.1 API interface, Here i will show you how you can get user timeline using the Twitter API so tight your seat belt and get set for interesting 5 minutes journey :

1) Login to your twitter API.
2) Open this URL : Register a Twitter APP
3) Fill all the required fields

  • Name : Your Unique Application Name (Do not use twitter word in it.)

  • Description: Your application description

  • Website: Your application's publicly accessible home page, where users can go to download, make use of, or find out more information about your application.

  • Callback URL(Optional) : This should be fully qualified domain name or IP where the API will return after successful authentication.


4) The next page will land toApplication Success Page
5) Click on setting tab on this page : SettingsTab
6) Check the application type to Read and Write
Read write
and hit update button.
7) Now click on third tab which is OAuth Tool for getting necessary platform access via API,copy the

  • Consumer key:

  • Consumer secret:

  • Access token: (You need to choose)

  • Access token secret: (You need to choose)

  • Request type: select it to GET


8) Now its time to get your hands dirty with coding, Are you ready ?
9) Download the latest TwitterAPIExchange.php This uses oAuth and the Twitter v1.1 API.

[php]
require_once('TwitterAPIExchange.php');

$url = 'https://api.twitter.com/1.1/followers/list.json';
$getfield = '?username=ravisoni6262&skip_status=1';
$requestMethod = 'GET';

$twitter = new TwitterAPIExchange($settings);
echo $twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest();
[/php]


The echo will successfully return you the some json response for your timeline.
For more you can read at API documentation

Hope it helps some one :-)

No comments:

Post a Comment