Send Yo from mbed. http://www.justyo.co/ Dependents: EthernetInterface, HTTPClient, mbed-rtos Example is http://mbed.org/users/hsgw/code/SendYoExample/
Revision 0:013176e14f42, committed 2014-06-25
- Comitter:
- hsgw
- Date:
- Wed Jun 25 13:14:43 2014 +0000
- Commit message:
- Initial commit
Changed in this revision
YoApi.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 013176e14f42 YoApi.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/YoApi.h Wed Jun 25 13:14:43 2014 +0000 @@ -0,0 +1,50 @@ +#ifndef _YO_API_H_ +#define _YO_API_H_ + +#include "HTTPClient.h" + +/** YoApi Library for mbed + * Copyright (c) 2014, Takuya Urakawa + * + * This library is released under the MIT License + * See http://opensource.org/licenses/mit-license.php + */ + +/** YoApi class + * + * Send Yo from mbed + */ + +class YoApi { +public: + +/** Constructor + * + * @param _http pointer to HTTPClient + * @param _apiToken Your Yo ApiToken + */ + YoApi(HTTPClient& _http, const char* _apiToken) + : mHttp(_http), mApiToken(_apiToken), API_URI("http://api.justyo.co/yoall/") + { + } + +/** send YO + * + * @return (int)0 on HTTP POST successed + */ + HTTPResult send(void){ + char returnStr[128]; + HTTPMap map; + HTTPText inText(returnStr, 128); + map.put("api_token", mApiToken); + return mHttp.post(API_URI, map, &inText); + } + + +private: + HTTPClient& mHttp; + const char* mApiToken; + const char* API_URI; +}; + +#endif