Skip to end of metadata
Go to start of metadata

Steps For Creating a Twitter Application

  1. Login to your twitter account (or signup if you don't already have one)
  2. Go to the developer page on twitter
  3. From here, click on Create an app
  4. Provide 
    1. a name to your app
    2. a short description
    3. a website url
    4. and a callbackurl (url that twitter will redirect to, after a user authorizes your application)
      and respond correctly to the captcha challenge

And you're done!

Twitter will show you the summary info of your application, including:

  • Consumer key
  • Consumer secret

And the default permission (will be set to read-only by default)

If the application you're developing needs to have write access to the account, you will need to specify that under the settings account.

 

Steps for authorizing your application

To access a certain account, you will need to first get the authorization of the account owner. The next step is to, using oauth, obrain access tokens.

Full documentation about twitter authentication scheme included here

 

What is required:

 

  • Consumer key
  • a Consumer secret
  • a callback page that twitter will redirect to once the user authorizes your app to access his account

The Flow

The process goes as follows:

  1. The website will provide the user with an authorization link; the link will look like this: https://api.twitter.com/oauth/authorize?oauth_token=some_oauth_token
    Obtaining the authorization url is done via an api call to the request token resource on twitter 
  2. The user clicks on the link, gets a dialog and either
    1. clicks on authorize (the case we're interested in)
    2. or clicks on decline
  3. The twitter dialog will redirect to the specified redirect_uri, including the request token, request token secret and the oauth verifier
  4. The application at the redirect_uri will
    1. read the oauth token parameter and identify the user (oauth token parameter is the request token returned from the get authorization url request)
    2. obtain an access token, based on the provided code

Generating the authorization url

Generating the authorization url is done using the apstrata scripting method:

apsdb.social.twitter.getRequestToken

 

apsdb.social.twitter.getRequestToken(AppId, AppSecret, redirect_uri)
ex:
apsdb.social.facebook.getRequestToken("444444444444444", "626262626262662626262", "http://www.domain.com/twitterAuthCallbackPage.php") 

the result of this call is going look like:

"result": {
"authorizationUrl": "https://api.twitter.com/oauth/authorize?oauth_token=5cPG4",
"requestToken": "5cPG4",
"requestSecret": "0hZLMbCW5dbcVq7SMigsxhDW6fk"
}

where authorizationUrl is the url the user needs to directed to, which will show him the "allow" button.

the request token and request secret will be user to identify the user when your application will get the redirect call.

 Obtaining the AccessToken/AccessTokenSecret Pair

Obtaining the AccessToken is done using the apstrata scripting method

apsdb.social.twitter.getAccessToken

 

apsdb.social.facebook.getAccessToken(ConsumerKey, ConsumerSecret, RequestToken, RequestTokenSecret, verifier)
ex:
apsdb.social.twitter.getAccessToken("444444444444444","626262626262662626262", "5cPG4", "0hZLMbCW5dbcVq7SMigsxhDW6fk", "YzQX8rPRaBQXegIGUR9I00lzah");

the response of this code will include a pair of AccessToken and AccessTokenSecret which will be used for all twitter access calls.

  • No labels