Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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 "YoutubeFeeds" Sample.

Info
titleNote

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/YoutubeFeeds.

2. The script will add an API to the API Publisher. Let's access Yahoo's place finder search function through this API.

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 "YoutubeFeeds" 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.

Code Block
curl -H "Authorization :Bearer 9nEQnijLZ0Gi0gZ6a3pZICktVUca" http://localhost:8280/youtube/1.0.0/most_popular

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,

Code Block
languagehtml/xml
<?xml version='1.0' encoding='UTF-8'?>
<feed xmlns='http://www.w3.org/2005/Atom' xmlns:app='http://purl.org/atom/app#'
xmlns:media='http://search.yahoo.com/mrss/' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'
xmlns:gd='http://schemas.google.com/g/2005' xmlns:yt='http://gdata.youtube.com/schemas/2007'>
<id>http://gdata.youtube.com/feeds/api/standardfeeds/most_popular</id>
<updated>2012-07-26T04:51:52.363-07:00</updated>
<category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#video'/>
<title type='text'>Most Popular</title>
<logo>http://www.youtube.com/img/pic_youtubelogo_123x63.gif</logo>
<link rel='alternate' type='text/html' href='http://www.youtube.com/browse?s=bzb'/>...

10. Access various other feeds in the Youtube API by changing the last segment of the invoked URL. For example,

Code Block
curl -H "Authorization :Bearer 9nEQnijLZ0Gi0gZ6a3pZICktVUca" http://localhost:8280/youtube/1.0.0/top_rated
curl -H "Authorization :Bearer 9nEQnijLZ0Gi0gZ6a3pZICktVUca" http://localhost:8280/youtube/1.0.0/most_shared
curl -H "Authorization :Bearer 9nEQnijLZ0Gi0gZ6a3pZICktVUca" http://localhost:8280/youtube/1.0.0/most_viewed 
Excerpt
hiddentrue

WSO2 API Manager Samples