Question

HTTPCaller and Twitter API authentication problems


Userlevel 4
Badge +13

I am currently starting a project requiring me to pull images and videos from a Twitter page. Originally, I was using the TwitterStatusFetcher transformer to pull the individual JSON object of every tweet, and extract the corresponding image and/or video. While this was working to an extent, I noticed that the JSON extracted from the TwitterStatusFetcher at times did not contain an image and/or video when there should've been one. I believe this is due to a recent change in Twitter's API requiring an extra parameter (tweet_mode=extended) to retrieve a full tweet.

 

As such, I've been trying to access the Twitter API directly with this extra parameter, using the HTTPCaller transformer. However, Twitter requires the use of Oauth 1.0 for me to pull tweets. I'm unsure of how to set up the web connection for Twitter to use Oauth 1.0, as FME 2016.1 uses Oauth 2.0 to establish a web service. I have all the required consumer and access tokens already, I'm just unsure of how to go about setting up the web connection. Any assistance would be appreciated.


4 replies

Badge +2

To authenticate the requests with Twitter I followed the instructions for the Application Only method https://dev.twitter.com/oauth/application-only

In the Twitter Developer section I created an Application and have obtained a Consumer Key (API Key) and a Consumer Secret (API Secret). I then followed the instructions here: https://dev.twitter.com/oauth/application-only and used a generic website to encode to Base64.

 

Inside the HTTPCaller I entered the required headers and query, using the encoded value for authorization.

 

 

Once I have the response from that call (the Bearer Token), I use a second HTTP Caller to execute the search with the correct authorization using the Bearer Token (copied from the response of the other HTTPCaller).

 

 

 

This should return a successful response from the Twitter search API. https://dev.twitter.com/rest/public/search
Userlevel 5
Badge +25

Could you explain what exactly you're supplying in that first HTTPCaller, in the greyed out bit? I've tried various things (API key, API secret, base64 API secret) but nothing seems to get a good response.

Userlevel 5
Badge +25

Could you explain what exactly you're supplying in that first HTTPCaller, in the greyed out bit? I've tried various things (API key, API secret, base64 API secret) but nothing seems to get a good response.

FWIW, I managed to work around my issue by using IFTTT

 

 

Badge +9

Could you explain what exactly you're supplying in that first HTTPCaller, in the greyed out bit? I've tried various things (API key, API secret, base64 API secret) but nothing seems to get a good response.

From looking here: https://dev.twitter.com/oauth/application-only under the heading Step 1: Encode consumer key and secret I believe what's used in that first HTTPCaller is the following string: APIkey:APIsecret (the key and secret concatenated together with a : separating them) encoded as Base64 (the BinaryEncoder transformer can handle the encoding step for you).

 

 

Reply