Unknown macro: {next_previous_links}
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Current »

Twitter API version 1.0 is retired from 11th June 2013 and the API version 1.1 cannot be accessed the way described in this sample

Before executing the sample, follow the instruction in section API Manager Samples. When you are done, you will have the API Manager started and the relevant scripts run to create user accounts for API Publisher and API Store. We have given below instructions specific to the "TwitterSearch" Sample.

Note

Scripts used in this sample will not work in Windows environments. Windows support will be added in the next API Manager release.

You can submit your suggestions at https://wso2.org/jira/browse/APISTORE. 

Deploy and Test the Sample

Follow the instructions below to deploy and test the sample.

1. First, we need to add an API in the API Publisher and publish it to the API Store. To do that, simply run the APIPopulator.sh (for Linux) or APIPopulator.bat (for Windows) files in folder, <PRODUCT_HOME>/samples/TwitterSearch.

2. The script will add an API to the API Publisher. 

3. Log in to the API Store (https://localhost:9443/store) with credentials subscriber1/subscriber1.

4. Click on the "Applications" tab at the top of the page of the API Store, and create a new application. Provide any name you prefer.

5. Click the "APIs" tab at the top of the page and select the "TwitterSearch" API. Next, subscribe to this API using the newly-created application. For instructions on subscribing to an API, refer to section Subscribing to an API.

6. Click the "My Subscriptions" tab at the top of the window and select your application. Click on the "Generate" option in the box titled "Production" to obtain an Application key.

7. Once you have obtained a key, you can invoke the API using a REST client of your choice. In this example, we use cURL (http://curl.haxx.se).

8. Copy and paste following into a new console window & execute it.

curl -k -d "q=wso2&count=5" -H "Authorization :Bearer 9nEQnijLZ0Gi0gZ6a3pZICktVUca" https://localhost:8243/twitter/1.0.0/search.atom

where, API key = 9nEQnijLZ0Gi0gZ6a3pZICktVUca. Replace this value with the API key you generated through the API Store in step 6 above.

9. You should be able to see search results from Twitter on your console. For example,

<feed xmlns="http://www.w3.org/2005/Atom" xmlns:twitter="http://api.twitter.com/" xmlns:georss="http://www.georss.org/georss"
xmlns:google="http://base.google.com/ns/1.0" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xml:lang="en-US">
<id>tag:search.twitter.com,2005:search/wso2</id>
<link type="text/html" href="http://search.twitter.com/search?q=wso2" rel="alternate" />
<link type="application/atom+xm..............

10. Executing the above command several times with different API keys. Note the authentication failures returned by the API gateway when you pass invalid API keys. After a few invocations, the throttling policy of the API will get activated and the API gateway will start responding with 503 Service Unavailable response messages.

  • No labels