![](/media/cache/profiles/5f14615696649541a025d3d0f8e0447f.jpg.50x50_q85.jpg)
IFTTTに引数付きでPOST出来る様に改修
Dependencies: EthernetInterface HTTPClient mbed-rtos mbed
Fork of HTTPClient_IFTTT_Maker_post_HelloWorld by
main.cpp
- Committer:
- kensuzuki
- Date:
- 2015-06-25
- Revision:
- 0:0bac9bcebae1
- Child:
- 1:b713347c7f63
File content as of revision 0:0bac9bcebae1:
#include "mbed.h" #include "EthernetInterface.h" #include "HTTPClient.h" EthernetInterface eth; HTTPClient http; char str[512]; HTTPText inData(str, 512); Serial pc(USBTX, USBRX); int ret; int main() { eth.init(); ret = eth.connect(); if (!ret) { pc.printf("ip: %s, %s, %s\r\n", eth.getIPAddress(), eth.getNetworkMask(), eth.getGateway()); } else { pc.printf("Ethernet connect failed. ret: %d\r\n", ret); return -1; } HTTPMap map; map.put("value1", "Somebody pushed my reset button."); ret = http.post("http://maker.ifttt.com/trigger/button_pushed/with/key/bdsJdNU9BdvTf3CrsAuBE5", map, &inData); if (!ret) { pc.printf("HTTP request succeeded.\r\n"); pc.printf("%s\r\n", str); } else { pc.printf("HTTP request failed. ret: %d, code: %d\r\n", ret, http.getHTTPResponseCode()); } eth.disconnect(); while(1) { } }