Fixed compatibility for HTTPClient Library. (HTTPClient by Donatien Garnier)

Dependents:   FlashAir_Twitter CyaSSL-Twitter-OAuth4Tw TweetTest NetworkThermometer ... more

Fork of OAuth4Tw by Masayoshi Takahashi

Revision:
3:c28b796ef7ed
Parent:
2:a057c813fb02
Child:
4:1ecf49a46040
--- a/OAuth4Tw.cpp	Mon Dec 15 12:24:37 2014 +0000
+++ b/OAuth4Tw.cpp	Wed Jul 08 03:52:54 2015 +0000
@@ -1,6 +1,11 @@
 #include "OAuth4Tw.h"
 #include "mbed.h"
-#include "oauth.h"
+#include "twicpps/oauth.h"
+
+#include <HTTPClient.h>
+#include "HTTPPostText.h"
+
+static char res_buffer[1024] = "";
 
 OAuth4Tw::OAuth4Tw(const char *c_key, const char *c_secret,
         const char *t_key, const char *t_secret)
@@ -16,12 +21,18 @@
 std::string OAuth4Tw::post(const char *uri, std::string postarg) {
 
     std::string req_url;
-    std::string postres;
     
     req_url = oauth_sign_url2(uri, &postarg, OA_HMAC, 0,
             consumer_key, consumer_secret, token_key, token_secret);
 
-    postres = oauth_http_post(req_url.c_str(), postarg.c_str());
-    return postres;
+    const char *u = req_url.c_str();
+    const char *p = postarg.c_str();
+    
+    HTTPClient http;
+    HTTPPostText req((char *)p, strlen(p) + 1);
+    HTTPText res(res_buffer, sizeof(res_buffer));
+    http.post(u, req, &res);
+
+    return res_buffer;
 }