Steps For Creating a Twitter Application
- Login to your twitter account (or signup if you don't already have one)
- Go to the developer page on twitter
- From here, click on Create an app
- a name to your app
- a short description
- a website url
- 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:
- a Consumer key
- a Consumer secret
- a callback page that twitter will redirect to once the user authorizes your app to access his account
The process goes as follows:
- 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
- The user clicks on the link, gets a dialog and either
- clicks on authorize (the case we're interested in)
- or clicks on decline
- The twitter dialog will redirect to the specified redirect_uri, including the request token, request token secret and the oauth verifier
- The application at the redirect_uri will
- read the oauth token parameter and identify the user (oauth token parameter is the request token returned from the get authorization url request)
- obtain an access token, based on the provided code
Generating the authorization url
Generating the authorization url is done using the apstrata scripting method:
the result of this call is going look like:
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("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.