Twitter's Example Code not working on Arduino



Hey guys, I’m new to the Twitter-Development-verse. I’m working on a mood light project with Twitter & Arduino and was testing my authorization key with the sample HTTPS request Twitter had here:

POST /1/statuses/update.json?include_entities=true HTTP/1.1
Accept: */*
Connection: close
User-Agent: OAuth gem v0.4.4
Content-Type: application/x-www-form-urlencoded
        OAuth oauth_consumer_key="xvxxxxxxxxxog", 
Content-Length: 76


I used client.println() to send these to the server, but I keep getting this in response:

HTTP/1.0 400 Bad Request
content-length: 0
date: Tue, 04 Aug 2015 19:58:49 GMT
server: tsa_a

Very confused – I used my own authorization keys from the ‘Test OAuth’ option we have, instead of the sample code’s, but outside of that it’s just a sample request. Hoping to springboard off of this to my own code so I can search for terms instead of posting tweets, but first, I’m really stuck on why this isn’t working. Any help?

Arduino WiFi Twitter Read Only, App Read Permission

I’ve just spotted that the “Creating a signature” page refers to /1/statuses/update.json, which is no longer valid - should be /1.1/ - we need to fix that.


Hi, thanks for your response! That’s definitely something any person who’s trying my approach should know in advance. However, I fixed that error and am still getting the same 400 Bad Request message sent back. :confused: Any ideas?


There are a bunch of things that can cause issues with OAuth, annoyingly. One example is that the time on the client and server needs to be very closely in line, or the server will reject the signature.

From the output of the command you posted in the original post, it looks like the response itself is truncated. Are you calling Twitter over HTTPS? I wasn’t sure that was possible from an Arduino?

Most (if not all) Arduino->Twitter scenarios I’ve worked on in the past have used something more capable upstream of the Arduino to do the actual call to Twitter, using one of the common open source client libraries. I had another similar discussion recently where I recommended a tool like Node-Red for doing the Twitter OAuth and update.