Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
12 years, 1 month ago.
working twitter library?
just recently used mbed, i see twitter libraries a year old, after trying some of those, it seems not to work anymore. are the developers abandoned their work?
was hoping this program to work, arduino didn't seem to get this kind of issue. specially to a newbie, who likes importing programs for learning purposes.
http://mbed.org/cookbook/Twitter ^ this seems promising, but documentation is poor. didnt bother explaining the error codes. i managed to get pass error code 5, by chaning the API link.
now im stucked to "error code 4" which i dont even have a clue what might cause it
Question relating to:
1 Answer
12 years, 1 month ago.
Hello.
The Twitter library you linked to uses the older "EtherNetIf" network library/stack. A newer library "EthernetInterface" is now used. Since it's an mbed official library, most of the cookbook libraries are not compatible. I think that is were Arduino is ahead of mbed.
You will need to include Kazushi Mukaiyama's fork of the HTTPClient as it includes support for Basic Authentication which is required by supertweet.
You will also need to change the URL to the newer v1.1 API: http://api.supertweet.net/1.1/statuses/update.json
Then use something like this to post to twitter:
Post to twitter with EthernetInterface
HTTPClient http; HTTPMap httpmsg; // Post a Tweet on Twitter using Supertweet API and basic authentication const char *TWITTER_USER = "twitterusername"; const char *TWITTER_PASSWORD = "password"; const char *TWITTER_TWEET = "twitter sucks and so does facebook!"; http.basicAuth(TWITTER_USER, TWITTER_PASSWORD); httpmsg.put("status", TWITTER_TWEET); DEBUG("posting to twitter..."); HTTPResult r = http.post(http://api.supertweet.net/1.1/statuses/update.json, httpmsg, NULL); bool tweet_ok = !r; if(tweet_ok) DEBUG("Tweet success!");
This is not a working example, but should get you started.