Thursday, 22 May 2014

Connecting to Twitter using HTTP Analyzer and OAuth Credentials

This document shows you how you can connect to twitter to fetch user timeline data via HTTP Analyzer.

In this sample, we will be accessing the user timelines API of Twitter to get a collection of the most recent tweets posted by a user. To communicate with Twitter, an application needs to pass through the OAuth authentication scheme. HTTP Analyzer supports OAuth 1.0 at the time of writing this post.

Use JDeveloper

1.      Open HTTP Analyzer by clicking on Tools -> HTTP Analyzer and select ‘Create New HTTP Request’.
2.      Create a new credential by clicking the New… button near the credential drop down. In the resulting Preferences window, add a new credential and call it ‘OAuthCredential’.

3.      Get your Consumer key (API Key) and consumer secret (API Secret) from Twitter. If you don’t have an app already registered, do so by visiting

4.      Feed the consumer key and consumer secret into the credential window opened in step 2. 
Signature Method: HMAC_SHA1
Request token URL:
Authorization URL:
Access token URL:

            The credential set-up is now done. Close the Preferences window and focus on the HTTP Analyzer.
5.      Supply the URL as This is the twitter URL we will be hitting to get the timeline details for a user with a given screen name. Select the Method as GET. Also, select the credential OAuthCredential created by you. The screen name and count parameters can be supplied in the Request body as shown. For details on the user timeline API, refer

6.       Ignore any warning that you get by clicking Yes. You will also be prompted to accept the Certificate as this is an HTTPS request. Go ahead and do so by clicking Accept. You will then be prompted to enter your Twitter credentials for authorization. Go ahead and enter your Twitter username and password, and click Authorize app.

      Once you authorize the app, you will see the below screen. Toggle back to HTTP Analyzer to see if you have got 200 Ok as response. Once you get a 200 Ok, it means your request has gone through fine.

7.   To see the response JSON structure, go to the HTTP Analyzer pane, where all the requests are listed. Ideally, the last request will have the complete JSON data.

No comments:

Post a Comment