How to connect to API 1.1 with javascript and arduino possibly using OAuth authentication?

LCDyhr
@LCDyhr Louise Callisen Dyhr

Help help help!

I have made a website + a project in Arduino that both fetches tweets from my own twitter account and acts according to these. Today the twitter API changed to version 1.1 and now my website doesn't work. I am supposted to present my project for an exam tomorrow, so I am in complete panic.

On my website I have been using javascript with this code:

var twitter_api_url = 'http://search.twitter.com/search.json';"
$.getJSON( twitter_api_url + '?callback=?&rpp=5&q=from:' + twitter_user, function(data) { ".

This is not working and I don't know how to change it.

In Arduino I call:

client.println("GET /1/statuses/user_timeline.xml?screen_name=MYTWITTER HTTP/1.1");
client.println("Host:api.twitter.com");
client.println("Connection:close");
client.println();

I get error message 410 (gone) and "The Twitter REST API v1 will soon stop functioning. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview".

I have tried searching for fixes but I can't find the correct solution. I think that I might need to make an OAuth authentication? I found a guide to create parametres for this "http://www.slideshare.net/Tweetganic/generate-twitter-applications", but I don't know how to add the parametres to javascript or Arduino.

I found a suggestion for Arduino:

client.print(F("GET /1/statuses/user_timeline.xml?screen_name=MYTWITTER HTTP/1.1"));
client.print(F("HOST: api.twitter.com"));
client.print(F("Authorization: OAuth oauth_consumer_key=\"XXX\", oauth_nonce=\"XXX\", oauth_signature=\"XXX\", oauth_signature_method=\"HMAC-SHA1\", oauth_timestamp=\"1361444134\", oauth_token=\"XXX\", oauth_version=\"1.0\""));
client.println();
client.println();

But I don't know what oauth_nonce and oauth_signature and oauth_timestamp is supposed to be. Another user also replied that this didn't work, so I don't know if I want to continue with it.

Can someone please help me, thanks?

45 weeks 1 day ago

Replies

lectno
@lectno lectno

http://www.slideshare.net/Tweetganic/generate-twitter-applications
here is the solution. you can find what you looking for on the site

44 weeks 4 days ago
timacheson
@timacheson Tim Acheson

Hi @LCDyhr -- if you want to continue using the API in JQuery like that, one easy way is just to add a small extra bit of code to act as a proxy between your JavaScript and the API.

E.g. How to use Twitter API 1.1 in JavaScript code, bypassing oAuth authentication on the client-side: http://www.timacheson.com/Blog/2013/jul/twitter_api_proxy

42 weeks 17 hours ago
saravan68005674
@saravan68005674 saravanan

Hi,
In your link , You are using server side scripting (http://www.timacheson.com/Blog/2013/jul/twitter_api_proxy)

Is it possible to use Twitter API 1.1 in JavaScript code, by passing oAuth authentication on the client-side scripting (JavaScript, JQuery).

28 weeks 3 days ago