IFTTTに引数付きでPOST出来る様に改修
Dependencies: EthernetInterface HTTPClient mbed-rtos mbed
Fork of HTTPClient_IFTTT_Maker_post_HelloWorld by
main.cpp
- Committer:
- jksoft
- Date:
- 2015-07-13
- Revision:
- 2:7101bf2516ef
- Parent:
- 1:b713347c7f63
File content as of revision 2:7101bf2516ef:
#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; HTTPText outText(str, 512); // map.put("value1", "Hello World."); outText = "{ \"value1\" : \"Hello World.\"}"; ret = http.post("http://maker.ifttt.com/trigger/button_pressed/with/key/YOUR_SECRET_KEY", outText, &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) { } }