Microcontroller Tweeting


#1

I am trying to send a tweet directly to the Twitter API from my microcontroller. In the documentation for authorizing a request, they give the following example:


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
Authorization:
OAuth oauth_consumer_key=“xvz1evFS4wEEPTGEFPHBog”,
oauth_nonce=“kYjzVBB8Y0ZFabxSWbWovY3uYSQ2pTgmZeNu2VS4cg”,
oauth_signature=“tnnArxj06cWHq44gCs1OSKk%2FjLY%3D”,
oauth_signature_method=“HMAC-SHA1”,
oauth_timestamp=“1318622958”,
oauth_token=“370773112-GmHxMAgYyLbNEtIKZeRNFsMKPR9EyMZeS9weJAEb”,
oauth_version="1.0"
Content-Length: 76
Host: api.twitter.com

status=Hello%20Ladies%20%2b%20Gentlemen%2c%20a%20signed%20OAuth%20request%21


If i send this information directly to the API (assuming that all the parameters have been changed in the above example use my values and they are correctly calculated), it should post the tweet, right?
For some reason I cannot get this process to work. (Is the API only on https? or is it http also?)


#2

Any help?


#3

Hi Evan,

The API for statuses/update is at both HTTP and HTTPS. What error do you get when you try this (both code, message, and response body)? I would verify that you’re access token (and app) are set to read-write permissions (as opposed to read-only). Also, verify the timestamp calculation on your device – the timestamp should be within 5 minutes or so of our own (which is returned in a Date HTTP header in every response, which you can use to adjust your timestamp on-the-fly if necessary). You may want to remove include_entities=true from the GET-line of the request if the OAuth implementation you’re using isn’t super about organizing the params correctly.


#4

Because this is all done on a microcontroller, i cannot directly see the response. I tried using Wireshark to sniff the packets that were sent and received, but couldn’t find anything.
When calculating the signature the base string example from twitter was:
POST&https%3A%2F%2Fapi.twitter.com%2F1%2Fstatuses%2Fupdate.json&include_entities%3Dtrue%26oauth_consumer…
If trying to use HTTP should the ‘s’ be dropped from “https”?
To connect to twitter, I open a socket to api.twitter.com and then send the POST data described in the first message above but with my values. (I also calculate the signature using my given consumer secret and my access token secret, since this is for individual use and there won’t be any other users. This is an acceptable method, correct?)
Thanks.


#5

bump…
and would you be able to tell me how far off a time is from the Twitter server? I am making an NTP request to pool.ntp.org and want to know how far off the time from there is from Twitter’s


#6

Hi Evan,
We have a project from the of the college, about sending a tweet through micro-controller,
It would be nice from you if you could send material and information about what you did.
my Email is:isolimani@gmail.com
Thanks a lot
Idan


#7

Hello Evan
I`m interested to do a microcontroller tweeting, but I need some information about the subject, I want to make it in a PIC18f452 MCU If you can help me about it please you send me information to rambal90@gmail.com
thanks a lot