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.

Files at this revision

API Documentation at this revision

Comitter:
donatien
Date:
Thu Aug 30 15:42:06 2012 +0000
Parent:
1:d263603373ac
Child:
3:561e6a2908ab
Commit message:
Updated library with fix, added example for PUT & DELETE requests

Changed in this revision

EthernetInterface.lib Show annotated file Show diff for this revision Revisions of this file
HTTPClient.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/EthernetInterface.lib	Sun Aug 05 16:12:30 2012 +0000
+++ b/EthernetInterface.lib	Thu Aug 30 15:42:06 2012 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/EthernetInterface/#2a797ba9babe
+http://mbed.org/users/mbed_official/code/EthernetInterface/#a0ee3ae75cfa
--- a/HTTPClient.lib	Sun Aug 05 16:12:30 2012 +0000
+++ b/HTTPClient.lib	Thu Aug 30 15:42:06 2012 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/donatien/code/HTTPClient/#be61104f4e91
+http://mbed.org/users/donatien/code/HTTPClient/#1f743885e7de
--- a/main.cpp	Sun Aug 05 16:12:30 2012 +0000
+++ b/main.cpp	Thu Aug 30 15:42:06 2012 +0000
@@ -13,7 +13,7 @@
     eth.connect();
     
     //GET data
-    printf("Trying to fetch page...\n");
+    printf("\nTrying to fetch page...\n");
     int ret = http.get("http://mbed.org/media/uploads/donatien/hello.txt", str, 128);
     if (!ret)
     {
@@ -27,11 +27,11 @@
     
     //POST data
     HTTPMap map;
-    HTTPText text(str, 512);
+    HTTPText inText(str, 512);
     map.put("Hello", "World");
     map.put("test", "1234");
-    printf("Trying to post data...\n");
-    ret = http.post("http://httpbin.org/post", map, &text);
+    printf("\nTrying to post data...\n");
+    ret = http.post("http://httpbin.org/post", map, &inText);
     if (!ret)
     {
       printf("Executed POST successfully - read %d characters\n", strlen(str));
@@ -42,6 +42,36 @@
       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());
+    }
+    
     eth.disconnect();  
 
     while(1) {