Fixed compatibility for HTTPClient Library. (HTTPClient by Donatien Garnier)
Dependents: FlashAir_Twitter CyaSSL-Twitter-OAuth4Tw TweetTest NetworkThermometer ... more
Fork of OAuth4Tw by
OAuth4Tw.cpp@3:c28b796ef7ed, 2015-07-08 (annotated)
- Committer:
- ban4jp
- Date:
- Wed Jul 08 03:52:54 2015 +0000
- Revision:
- 3:c28b796ef7ed
- Parent:
- 2:a057c813fb02
- Child:
- 4:1ecf49a46040
Change the folder structure.; Updated code from twicpps. (just a little.)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
takahashim | 0:0048b264a3ad | 1 | #include "OAuth4Tw.h" |
takahashim | 0:0048b264a3ad | 2 | #include "mbed.h" |
ban4jp | 3:c28b796ef7ed | 3 | #include "twicpps/oauth.h" |
ban4jp | 3:c28b796ef7ed | 4 | |
ban4jp | 3:c28b796ef7ed | 5 | #include <HTTPClient.h> |
ban4jp | 3:c28b796ef7ed | 6 | #include "HTTPPostText.h" |
ban4jp | 3:c28b796ef7ed | 7 | |
ban4jp | 3:c28b796ef7ed | 8 | static char res_buffer[1024] = ""; |
takahashim | 0:0048b264a3ad | 9 | |
takahashim | 0:0048b264a3ad | 10 | OAuth4Tw::OAuth4Tw(const char *c_key, const char *c_secret, |
takahashim | 0:0048b264a3ad | 11 | const char *t_key, const char *t_secret) |
takahashim | 0:0048b264a3ad | 12 | :consumer_key(c_key), |
takahashim | 0:0048b264a3ad | 13 | consumer_secret(c_secret), |
takahashim | 0:0048b264a3ad | 14 | token_key(t_key), |
takahashim | 0:0048b264a3ad | 15 | token_secret(t_secret) { } |
takahashim | 0:0048b264a3ad | 16 | |
takahashim | 0:0048b264a3ad | 17 | std::string OAuth4Tw::url_escape(const char *str) { |
takahashim | 0:0048b264a3ad | 18 | return oauth_url_escape(str); |
takahashim | 0:0048b264a3ad | 19 | } |
takahashim | 0:0048b264a3ad | 20 | |
takahashim | 0:0048b264a3ad | 21 | std::string OAuth4Tw::post(const char *uri, std::string postarg) { |
takahashim | 0:0048b264a3ad | 22 | |
takahashim | 0:0048b264a3ad | 23 | std::string req_url; |
takahashim | 0:0048b264a3ad | 24 | |
takahashim | 0:0048b264a3ad | 25 | req_url = oauth_sign_url2(uri, &postarg, OA_HMAC, 0, |
takahashim | 0:0048b264a3ad | 26 | consumer_key, consumer_secret, token_key, token_secret); |
takahashim | 0:0048b264a3ad | 27 | |
ban4jp | 3:c28b796ef7ed | 28 | const char *u = req_url.c_str(); |
ban4jp | 3:c28b796ef7ed | 29 | const char *p = postarg.c_str(); |
ban4jp | 3:c28b796ef7ed | 30 | |
ban4jp | 3:c28b796ef7ed | 31 | HTTPClient http; |
ban4jp | 3:c28b796ef7ed | 32 | HTTPPostText req((char *)p, strlen(p) + 1); |
ban4jp | 3:c28b796ef7ed | 33 | HTTPText res(res_buffer, sizeof(res_buffer)); |
ban4jp | 3:c28b796ef7ed | 34 | http.post(u, req, &res); |
ban4jp | 3:c28b796ef7ed | 35 | |
ban4jp | 3:c28b796ef7ed | 36 | return res_buffer; |
takahashim | 0:0048b264a3ad | 37 | } |
takahashim | 0:0048b264a3ad | 38 |