a

Dependencies:   EthernetNetIf HTTPClient mbed

Fork of TwitterExample by Donatien Garnier

Revision:
0:96e3b1c49f9b
Child:
2:2a9775a81062
diff -r 000000000000 -r 96e3b1c49f9b TwitterExample.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TwitterExample.cpp	Mon Jun 14 10:29:54 2010 +0000
@@ -0,0 +1,40 @@
+#include "mbed.h"
+#include "EthernetNetIf.h"
+#include "HTTPClient.h"
+
+EthernetNetIf eth; 
+
+int main() {
+
+  printf("Init\n");
+
+  printf("\r\nSetting up...\r\n");
+  EthernetErr ethErr = eth.setup();
+  if(ethErr)
+  {
+    printf("Error %d in setup.\n", ethErr);
+    return -1;
+  }
+  printf("\r\nSetup OK\r\n");
+
+  HTTPClient twitter;
+  
+  HTTPMap msg;
+  msg["status"] = "I am tweeting from my mbed!"; //A good example of Key/Value pair use with Web APIs
+
+  twitter.basicAuth("myuser", "mypass"); //We use basic authentication, replace with you account's parameters
+  
+  //No need to retieve data sent back by the server
+  HTTPResult r = twitter.post("http://twitter.com/statuses/update.xml", msg, NULL); 
+  if( r == HTTP_OK )
+  {
+    printf("Tweet sent with success!\n");
+  }
+  else
+  {
+    printf("Problem during tweeting, return code %d\n", r);
+  }
+  
+  return 0;
+
+}