Tuesday, October 11, 2016

OTN Appreciation Day: #ThanksOTN Twitter feed with Oracle MCS and Oracle JET

As we can implement our Custom APIs using node.js, we can almost use any of the available node modules like for example Oracle MCS: Creating PDF files in Custom APIs.
In a project we are developing we have the requirement to display a twitter timeline of a hashtag.

Today is the OTN Appreciation Day and in this post we are going to make a #ThanksOTN twitter feed using Oracle MCS and Oracle JET.

First of all we are going to start with the API design. We are going to create an API called TwitterAPI and a GET method inside feed endpoint.

The next step is to implement the API. To get the twitter feed we are going to use node-twitter module.  To install the module we have to execute npm install twitter  in the folder where our package.json file is.

After that we need to include the module as a dependency.

Moving to the javascript part, this is the implementation.

To get the consumer_key, consumer_secret, access_token_key and access_token_secret we need to create a twitter application. We are just returning the json that the module returns but we could implement something that caches the json and we just call the module every certain amount of time.

To finish the MCS part we have to upload the implementation zip file to MCS.

Moving to JET side, first we need to manually install the MCS library that can be found in your MCS instance.

Then the JET implementation looks like this:

 If we run the application we can see #ThanksOTN feed!