Twitter based on Neocat's Arduino Twiiter Lib

Dependencies:   EthernetInterface HTTPClient mbed-rtos mbed

Fork of HTTPClient_HelloWorld by Donatien Garnier

Visit http://mbedtweet.appspot.com to get the token required for this demo.

Revision:
3:561e6a2908ab
Parent:
2:270e2d0bb85a
--- a/main.cpp	Thu Aug 30 15:42:06 2012 +0000
+++ b/main.cpp	Mon Sep 24 10:13:13 2012 +0000
@@ -1,37 +1,34 @@
+/*----------------------------------------------------------------
+-                                                                -
+-  Simple twitter demo application                               -
+-  http://mbedtweet.appspot.com/                                 -
+-  Written by Escalion, based on ArduinoTweetLib by NeoCat       -
+-                                                                -
+----------------------------------------------------------------*/
 #include "mbed.h"
 #include "EthernetInterface.h"
 #include "HTTPClient.h"
 
+Serial pc(USBTX, USBRX); // tx, rx
 EthernetInterface eth;
 HTTPClient http;
 char str[512];
+char ret;
+const char *DATA = "Test Tweet From Mbed!";
+const char *TOKEN = ""; //get this from http://mbedtweet.appspot.com/
 
 int main() 
 {
     eth.init(); //Use DHCP
 
     eth.connect();
-    
-    //GET data
-    printf("\nTrying to fetch page...\n");
-    int ret = http.get("http://mbed.org/media/uploads/donatien/hello.txt", str, 128);
-    if (!ret)
-    {
-      printf("Page fetched successfully - read %d characters\n", strlen(str));
-      printf("Result: %s\n", str);
-    }
-    else
-    {
-      printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
-    }
-    
     //POST data
     HTTPMap map;
     HTTPText inText(str, 512);
-    map.put("Hello", "World");
-    map.put("test", "1234");
-    printf("\nTrying to post data...\n");
-    ret = http.post("http://httpbin.org/post", map, &inText);
+    map.put("token", TOKEN);
+    map.put("status", DATA);
+    printf("\nSending server tweet...\n");
+    ret = http.post("http://mbedtweet.appspot.com/update", map, &inText);
     if (!ret)
     {
       printf("Executed POST successfully - read %d characters\n", strlen(str));
@@ -39,37 +36,7 @@
     }
     else
     {
-      printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
-    }
-    
-    //PUT data
-    strcpy(str, "This is a PUT test!");
-    HTTPText outText(str);
-    //HTTPText inText(str, 512);
-    printf("\nTrying to put resource...\n");
-    ret = http.put("http://httpbin.org/put", outText, &inText);
-    if (!ret)
-    {
-      printf("Executed PUT successfully - read %d characters\n", strlen(str));
-      printf("Result: %s\n", str);
-    }
-    else
-    {
-      printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
-    }
-    
-    //DELETE data
-    //HTTPText inText(str, 512);
-    printf("\nTrying to delete resource...\n");
-    ret = http.del("http://httpbin.org/delete", &inText);
-    if (!ret)
-    {
-      printf("Executed DELETE successfully - read %d characters\n", strlen(str));
-      printf("Result: %s\n", str);
-    }
-    else
-    {
-      printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode());
+      printf("Error - ret = %d - HTTP return code = %d\n", str, http.getHTTPResponseCode());
     }
     
     eth.disconnect();