I’m using an Arduino Uno board with the Ethernet Shield to get the last tweet (of Twitter) from a public user timeline (it’s mine) and display it on the Arduino serial monitor. I want the whole device to work without Python or Ruby and as it’s a stand alone project it won’t be used with a computer.
I create a client that connects to api.twitter.com and I use this GET command of the REST API v1.0 to obtain it:
client.print("GET /1/statuses/user_timeline.json?&screen_name=tuitduino&count=1 HTTP/1.1"); client.println("HOST: api.twitter.com"); client.println();
It works properly, but according to the Twitter’s API documentation (https://dev.twitter.com/docs/api/1.1/get/statuses/user_timeline), I must change my GET command to the new version 1.1. This is what I do:
client.print("GET /1.1/statuses/user_timeline.json?&screen_name=tuitduino&count=1 HTTP/1.1"); client.println("HOST: api.twitter.com"); client.println();
but it doesn’t work. According to the Twitter’s API documentation, I must use OAuth to access this information, that is, to authenticate and authorize an aplication, wich I must create (in my case I suppose that it have to be a website), to read or write tweets from a user account (mine’s) on behalf of it. The problem is that I don’t know how to integrate the GET HTTP request and the OAuth information with my Arduino code. I’ve seen the Twitter’s API documentation in depth and there are a few examples and libraries to do it “easily” but they are written for other programming languages, not for Arduino.
According to the documentation, I must implement a header, something like this:
Authorization: OAuth oauth_consumer_key="cCB46H0y6R8Hrx836WwAA", oauth_nonce="18106fa9ce0b1083367cfbd50720abea", oauth_signature="XXXXXXXXXXXXXXXXXXXXXXX", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1361444134", oauth_token="1004705586-tF4876Qu6qTwLMuTaCjbZCLTbFt4hDoRoCun3qW", oauth_version="1.0"
where the alphanumeric values are given to me from Twitter and XXXXXXXXXXXXXXXXXXXXXXX is a private value so I omitted it.
Does anybody has some idea to do it with Arduino? The GET method and the header. It’s very important for me because it’s for my final project.