Twitter client that can be directly tweet. (Intermediate server is not required.)

Dependencies:   EthernetInterface HTTPClient-wolfSSL NTPClient OAuth4Tw mbed-rtos mbed wolfSSL

Fork of OAuth4Tw by Atsuya Okazaki

Files at this revision

API Documentation at this revision

Comitter:
ban4jp
Date:
Tue Jul 14 09:54:39 2015 +0000
Parent:
4:fcadeb9bdcbd
Child:
6:f5189d4f109f
Commit message:
a new example of the post API.

Changed in this revision

HTTPClient.lib Show annotated file Show diff for this revision Revisions of this file
OAuth4Tw.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
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/HTTPClient.lib	Wed Jul 08 14:55:36 2015 +0000
+++ b/HTTPClient.lib	Tue Jul 14 09:54:39 2015 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/users/ban4jp/code/HTTPClient-wolfSSL/#7bc63b8646f6
+http://developer.mbed.org/users/ban4jp/code/HTTPClient-wolfSSL/#81e61bd85dae
--- a/OAuth4Tw.lib	Wed Jul 08 14:55:36 2015 +0000
+++ b/OAuth4Tw.lib	Tue Jul 14 09:54:39 2015 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/users/ban4jp/code/OAuth4Tw/#1ecf49a46040
+http://developer.mbed.org/users/ban4jp/code/OAuth4Tw/#5146becb651f
--- a/main.cpp	Wed Jul 08 14:55:36 2015 +0000
+++ b/main.cpp	Tue Jul 14 09:54:39 2015 +0000
@@ -13,7 +13,13 @@
               "000000000-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", // Access token
               "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");     // Access token secret
 
-static char res_buffer[1024] = "";
+#if defined(TARGET_LPC1768)
+static char res_buffer[512];
+#elif defined(TARGET_K64F)
+static char res_buffer[4096];
+#else
+#error not tested platform.
+#endif
 
 int main()
 {
@@ -75,9 +81,9 @@
     HTTPText res(res_buffer, sizeof(res_buffer));
 
     while (1) {
+#if 0
         {
             char url[128];
-            char post[128]; //TODO: fix required. need saving memory.
 
             time(&ctTime);
 
@@ -85,20 +91,45 @@
                      "https://api.twitter.com/1.1/statuses/update.json"
                      "?status=Hello World! - %s", ctime(&ctTime));
 
-            HTTPResult result = oa4t.post(url, post, &res);
+            res_buffer[0] = '\0';
+            HTTPResult result = oa4t.post(url, &res);
             printf("POST result = %d\n%s\n", result, res_buffer);
         }
+#else
+        {
+            std::vector<std::string> post;
+            post.reserve(3);
+
+            char status[64];
+            char location_lat[24];
+            char location_long[24];
+
+            time(&ctTime);
+
+            snprintf(status, sizeof(status), "status=Hello Fujiyama! - %s", ctime(&ctTime));
+            snprintf(location_lat, sizeof(location_lat), "lat=%f", 35.359577);
+            snprintf(location_long, sizeof(location_long), "long=%f", 138.731414);
+            post.push_back(status);
+            post.push_back(location_lat);
+            post.push_back(location_long);
+
+            res_buffer[0] = '\0';
+            HTTPResult result = oa4t.post("https://api.twitter.com/1.1/statuses/update.json", &post, &res);
+            printf("POST result = %d\n%s\n", result, res_buffer);
+        }
+#endif
 
         {
             const char url[] = "https://api.twitter.com/1.1/users/show.json"
                                "?screen_name=twitter";
 
+            res_buffer[0] = '\0';
             HTTPResult result = oa4t.get(url, &res);
             printf("GET result = %d\n%s\n", result, res_buffer);
         }
 
-        // Wait 300 seconds for next time.
-        for (int t=0; t<300; t++) {
+        // Wait 60 seconds for next time.
+        for (int t=0; t<60; t++) {
             myled = 1;
             wait(0.2);
             myled = 0;
--- a/mbed-rtos.lib	Wed Jul 08 14:55:36 2015 +0000
+++ b/mbed-rtos.lib	Tue Jul 14 09:54:39 2015 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/users/mbed_official/code/mbed-rtos/#e695cd34556b
+http://developer.mbed.org/users/mbed_official/code/mbed-rtos/#5aed8bae1001
--- a/mbed.bld	Wed Jul 08 14:55:36 2015 +0000
+++ b/mbed.bld	Tue Jul 14 09:54:39 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/7cff1c4259d7
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/da0ca467f8b5
\ No newline at end of file