Hi, Have a loook at this code for some ideas. This code connects
// a brute test of twittering with arduino. // source for handling the twitter api was http://pratham.name/post/39551949/twitter-php-script-without-curl // the scetch lacks a lot of functionality, the encoding of username and password must be done separately // and the message is fixed (text is "Yahoo, im twittering!") // // this is due to my ony basic knowledge // maybe someone can use this snippet and have fun with it #include <Ethernet.h> byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; byte ip[] = { 192, 168, 2, 10 }; // this is the ip within my lan byte gateway[] = { 192, 168, 2, 1 }; // neccessary to get access to the internet via your router byte subnet[] = { 255, 255, 255, 0 }; byte server[] = { 128, 121, 146, 100 }; // Twitter's ip Client client(server, 80); void setup() { Ethernet.begin(mac, ip, gateway, subnet); Serial.begin(9600); delay(1000); Serial.println("connecting..."); if (client.connect()) { Serial.println("connected"); client.println("POST http://twitter.com/statuses/update.json HTTP/1.1"); client.println("Host: twitter.com"); client.println("Authorization: Basic #################"); // the string of ###s after "Basic" is the base64_encoded Text of username:password of your twitter account // you can do the encoding at this site: http://www.functions-online.com/en/base64_encode.html client.println("Content-type: application/x-www-form-urlencoded"); client.println("Content-length: 28"); // this is the length of the text "Yahoo, im twittering!" client.println("Connection: Close"); client.println(); client.print("status=Yahoo, im twittering!"); } else { Serial.println("connection failed"); } } void loop() { if (client.available()) { char c = client.read(); Serial.print(c); } if (!client.connected()) { Serial.println(); Serial.println("disconnecting."); client.stop(); for(;;) ; } } On Sat, Feb 19, 2011 at 8:09 AM, dl1sdz <dl1...@googlemail.com> wrote: > Hello, > > I try to code a fun project MorseTweeter. > > http://hajos-kontrapunkte.blogspot.com/2011/01/morsetweeter-v-07-is-running.html > > After a lot of research I came back and wanted to use the Arduino > standalone. But here I got stuck in formulating the query: > <snippet> > byte server[] = { 128, 242, 240, 148 }; // search twitter > // Make a HTTP request: > client.println("GET /search.atom?q=Morse&rpp=1 HTTP/1.1 "); > client.println("Host: search.twitter.com"); > client.println("Accept: text/xml;q=0.9"); > client.println(); > </ snippet> > > I always get an error 406. > <snippet> > connected > Using Server: 128.242.240.148 > HTTP/1.1 406 Not Acceptable > Date: Fri, 18 Feb 2011 22:11:11 GMT > Server: hi > Status: 406 Not Acceptable > X-Transaction: 1298067070-49239-28953 > X-RateLimit-Limit: 150 > Last-Modified: Fri, 18 Feb 2011 22:11:10 GMT > X-RateLimit-Remaining: 131 > X-Runtime: 0.08282 > X-Transaction-Mask: 0b5b266a28469a7b52ded76c9a66f018 > Content-Type: text/html; charset=utf-8 > Content-Length: 1 > Pragma: no-cache > X-RateLimit-Class: api > X-Revision: DEV > Expires: Tue, 31 Mar 1981 05:00:00 GMT > Cache-Control: no-cache, no-store, must-revalidate, pre-check=0, post- > check=0 > X-RateLimit-Reset: 1298067366 > .... > Connection: close > </snippet> > > If I only write: > <snippet> > client.println("GET /search.atom?q=Morse&rpp=1"); > client.println(); > </ snippet> > This also does not work. > > I know that the search has to be URL-encoded, but GET is accepted. I > read a lot of documentation but missed the point. > > It is only fun but help would be appreciated. > > Hajo > > -- > Twitter developer documentation and resources: http://dev.twitter.com/doc > API updates via Twitter: http://twitter.com/twitterapi > Issues/Enhancements Tracker: > http://code.google.com/p/twitter-api/issues/list > Change your membership to this group: > http://groups.google.com/group/twitter-development-talk > -- http://1537news.com/ Follow Us on Twitter <http://twitter.com/1537news/> Facebook Fan Page<http://www.facebook.com/profile.php?id=100000680443959#%21/pages/1537News/143582755669105?v=wall> -- Twitter developer documentation and resources: http://dev.twitter.com/doc API updates via Twitter: http://twitter.com/twitterapi Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list Change your membership to this group: http://groups.google.com/group/twitter-development-talk