Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Bhargavakrishna
Active Contributor

In this blog, I am going to focus on how to access real-time social media information using the Twitter [Receiver] adapter which was released on 2015-10-24 as part of SAP Hana Cloud Integration [HCI].


 

Introduction

Twitter is a social networking and micro-blogging service that enables its users to send and read messages known as tweets. Tweets are text-based posts of up to 140 characters displayed on the author’s profile page and delivered to the author’s subscribers who are known as followers.


The Twitter adapter provides an easy way of integrating a flow of tweets. Once configured correctly with Twitter credentials, all that is necessary is to implement the Twitter listener, instantiate the adapter, and handle the objects received.


We can use the Twitter receiver adapter to extract information from the Twitter platform (which is the receiver platform) based on certain criteria such as keywords, and user data. We can also perform a Twitter search based on a schedule and publish the search results within Messages.


 


To communicate with Twitter only as the currently authenticated user, then you can obtain the OAuthAccessToken and OAuthAccessTokenSecret directly from this page on Twitter. The OAuthAccessToken and OAuthAccessTokenSecret are listed under the OAuth Settings in the Your Access Token section.


For authenticated operations, Twitter uses OAuth - an authentication protocol that allows users to approve an application to act on their behalf without sharing their password. The connection works the way that the tenant logs on to Twitter based on an OAuth authentication mechanism and searches for information based on criteria as configured in the adapter at design time. OAuth allows the tenant to access someone else’s resources (of a specific Twitter user) on behalf of the tenant.


In order to use OAuth authentication/authorization with Twitter you must create a new Application on the Twitter Developers site. Follow the directions below to create a new application and obtain consumer keys and an access token.





  • Click on the Register an App link and fill out all required fields on the form provided; set Application Type to Client and depending on the nature of your application select Default Access Type as Read & Write or Read-only and Submit the form. If everything is successful you’ll be presented with the Consumer Key and Consumer Secret. Copy both values in a safe place.

  • On the same page, you should see a My Access Token button on the sidebar (right). Click on it and you’ll be presented with two more values: Access Token and Access Token Secret. Copy these values in a safe place as well.


Twitter receiver adapter features

Adapter Type:         Twitter

Messages Protocol: HTTPS

 

Operations

Twitter adapter provides send tweet, search, and send direct message operations. To access your Twitter account you can choose the following operations.

  • Send Tweet - This allows you to send content to a specific user timeline.

  • Search - Allows you to do a search on Twitter content by specifying keywords under filter settings.

  • Send direct message - Allows you to send messages to Twitter (write access, direct message).

  • Page size - specifies the maximum number of tweets per page.

  • Number of pages - Number of pages to consume.


 

Authentication methods

Twitter adapter supports basic authentication and OAuth mechanism based on the shared secret technology. We should make a note of the below parameters while doing Twitter configuration and we need to specify the same in the receiver twitter adapter.


We must specify both the OAuthClientId [Consumer Key] and OAuthClientSecret [Consumer Secret] to connect to an OAuth server.




  • Consumer Key


       OAuth requires you to register your application. As part of the registration, you will receive a client ID, sometimes also called a consumer key and a client secret. An alias by which the consumer (tenant) that requests Twitter resources is identified by using this OAuthClientid / Consumer key.

  • Consumer Secret


       OAuth requires you to register your application. As part of the registration you will receive a client ID and a client secret, sometimes also called a consumer secret. An alias by which the shared secret is identified (that is used to define the token of the consumer (tenant).

  • Access token


       The OAuthAccessToken property is used to connect using OAuth. The OAuthAccessToken is retrieved from the OAuth server as part of the authentication process. It has a server-dependent timeout and can be reused between requests.

 

       The access token is used in place of your username and password. It also protects your credentials by keeping them on the server. In order to make authorized calls to the TwitterAPI, your application must first obtain an OAuth access token on behalf of a Twitter user.

  • Access Token Secret


       The OAuthAccessTokenSecret property is used to connect and authenticate using OAuth. The OAuthAccessTokenSecret is retrieved from the OAuth server as part of the authentication process. It is used with the OAuthAccessToken and can be used for multiple requests until it times out.

Twitter Adapter Documentation & Download Links


https://proddps.hana.ondemand.com/dps/d/preview/93810d568bee49c6b3d7b5065a30b0ff/2015.10/en-US/frame...


http://scn.sap.com/community/pi-and-soa-middleware/blog/2016/03/02/integrating-hci-with-twitter--par...


  http://scn.sap.com/community/pi-and-soa-middleware/blog/2016/03/02/integrating-hci-with-twitter--par...

Labels in this area