Tiny HTTP Client
Tiny HTTP Client
簡易HTTPクライアントプログラム。
ネットワーク関係のライブラリをてんこ盛りにしたら暴走しだす、メモリーの残り容量が気になるプロダクト向け。
Import programTinyHTTP
Tiny HTTP Client http://mbed.org/users/okini3939/notebook/tinyhttp
GET
Host host;
host.setName("mbed.org");
httpRequest(METHOD_GET, &host, "/", NULL, NULL);
POST
Host host;
host.setName("mbed.org");
httpRequest(METHOD_POST, &host, "/", NULL, "key=value&key2=value2");
Twitter へも投稿できる。(SuperTweet.net使用)
Host host;
char buf[300], head[160];
// header
createauth("username", "password", head, sizeof(head));
strncat(head, "Content-type: application/x-www-form-urlencoded\r\n", sizeof(head) - strlen(head));
// post data
strcpy(buf, "status=");
urlencode("tweet messages", &buf[strlen(buf)], sizeof(buf) - strlen(buf));
host.setName("api.supertweet.net");
httpRequest(METHOD_POST, &host, "/1/statuses/update.xml", head, buf);
もちろん、Pachube にも対応。
Pachube
Host host;
char uri[40], head[160];
char buf[] = "1000,30,70" // data
// header
snprintf(head, sizeof(head), "Content-type: text/csv\r\nX-PachubeApiKey: %s\r\n", "API KEY");
// uri
snprintf(uri, sizeof(uri), "/v1/feeds/%d.csv?_method=put", 99999); // feed id
host.setName("api.pachube.com");
httpRequest(METHOD_POST, &host, uri, head, buf);
Please log in to post comments.
