Twitter library use the Stewgate U for PHS Shield. see: https://developer.mbed.org/users/phsfan/notebook/phsshield/

Dependents:   PHSShield_Twitter

Revision:
1:6ffd13808295
Parent:
0:4fc466e9fb48
--- a/Stewitter_a3gs.cpp	Wed Apr 01 06:15:12 2015 +0000
+++ b/Stewitter_a3gs.cpp	Mon Jun 22 14:50:41 2015 +0000
@@ -28,22 +28,23 @@
 bool Stewitter_a3gs::post(const char *msg)
 {
     int r;
-    char buf[512];
+    char buf[a3gsMAX_RESULT_LENGTH + 1];
     statusCode = 0;
     parseStatus = 0;
     httpBody[0] = 0;
 
     int length = a3gsMAX_RESULT_LENGTH;
-    char header[128], body[256];
+    char header[40], body[a3gsMAX_BODY_LENGTH];
     if (msg != NULL) {
-        sprintf(body, "_t=%s&msg=%s", token, msg);
-        sprintf(header, "Content-Length: %d", strlen(body));
+        snprintf(body, sizeof(body), "_t=%s&msg=%s", token, msg);
+        snprintf(header, sizeof(header), "Content-Length: %d", strlen(body));
         r = _a3gs.httpPOST(STEWGATE_HOST, 80, STEWGATE_POST_API, header, body, buf, &length, false);
+        if (r == 0) _a3gs.read(&buf[length], sizeof(buf) - length);
     } else {
-        sprintf(body, "_t=%s", token);
-        sprintf(header, "Content-Length: %d", strlen(body));
+        snprintf(body, sizeof(body), "_t=%s", token);
+        snprintf(header, sizeof(header), "Content-Length: %d", strlen(body));
         r = _a3gs.httpPOST(STEWGATE_HOST, 80, STEWGATE_LAST_MENTION_API, header, body, buf, &length, false);
-        _a3gs.read(&buf[length], sizeof(buf) - length);
+        if (r == 0) _a3gs.read(&buf[length], sizeof(buf) - length);
     }
 
     if (r == 0) {