Send Yo from mbed. http://www.justyo.co/ Dependents: EthernetInterface, HTTPClient, mbed-rtos Example is http://mbed.org/users/hsgw/code/SendYoExample/

Dependents:   SendYoExample

Committer:
hsgw
Date:
Wed Jun 25 13:14:43 2014 +0000
Revision:
0:013176e14f42
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hsgw 0:013176e14f42 1 #ifndef _YO_API_H_
hsgw 0:013176e14f42 2 #define _YO_API_H_
hsgw 0:013176e14f42 3
hsgw 0:013176e14f42 4 #include "HTTPClient.h"
hsgw 0:013176e14f42 5
hsgw 0:013176e14f42 6 /** YoApi Library for mbed
hsgw 0:013176e14f42 7 * Copyright (c) 2014, Takuya Urakawa
hsgw 0:013176e14f42 8 *
hsgw 0:013176e14f42 9 * This library is released under the MIT License
hsgw 0:013176e14f42 10 * See http://opensource.org/licenses/mit-license.php
hsgw 0:013176e14f42 11 */
hsgw 0:013176e14f42 12
hsgw 0:013176e14f42 13 /** YoApi class
hsgw 0:013176e14f42 14 *
hsgw 0:013176e14f42 15 * Send Yo from mbed
hsgw 0:013176e14f42 16 */
hsgw 0:013176e14f42 17
hsgw 0:013176e14f42 18 class YoApi {
hsgw 0:013176e14f42 19 public:
hsgw 0:013176e14f42 20
hsgw 0:013176e14f42 21 /** Constructor
hsgw 0:013176e14f42 22 *
hsgw 0:013176e14f42 23 * @param _http pointer to HTTPClient
hsgw 0:013176e14f42 24 * @param _apiToken Your Yo ApiToken
hsgw 0:013176e14f42 25 */
hsgw 0:013176e14f42 26 YoApi(HTTPClient& _http, const char* _apiToken)
hsgw 0:013176e14f42 27 : mHttp(_http), mApiToken(_apiToken), API_URI("http://api.justyo.co/yoall/")
hsgw 0:013176e14f42 28 {
hsgw 0:013176e14f42 29 }
hsgw 0:013176e14f42 30
hsgw 0:013176e14f42 31 /** send YO
hsgw 0:013176e14f42 32 *
hsgw 0:013176e14f42 33 * @return (int)0 on HTTP POST successed
hsgw 0:013176e14f42 34 */
hsgw 0:013176e14f42 35 HTTPResult send(void){
hsgw 0:013176e14f42 36 char returnStr[128];
hsgw 0:013176e14f42 37 HTTPMap map;
hsgw 0:013176e14f42 38 HTTPText inText(returnStr, 128);
hsgw 0:013176e14f42 39 map.put("api_token", mApiToken);
hsgw 0:013176e14f42 40 return mHttp.post(API_URI, map, &inText);
hsgw 0:013176e14f42 41 }
hsgw 0:013176e14f42 42
hsgw 0:013176e14f42 43
hsgw 0:013176e14f42 44 private:
hsgw 0:013176e14f42 45 HTTPClient& mHttp;
hsgw 0:013176e14f42 46 const char* mApiToken;
hsgw 0:013176e14f42 47 const char* API_URI;
hsgw 0:013176e14f42 48 };
hsgw 0:013176e14f42 49
hsgw 0:013176e14f42 50 #endif