An Example of triggering IFTTT Maker event.
Dependencies: EthernetInterface HTTPClient mbed-rtos mbed
Diff: main.cpp
- Revision:
- 0:0bac9bcebae1
- Child:
- 1:b713347c7f63
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Jun 25 11:40:49 2015 +0000 @@ -0,0 +1,40 @@ +#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) { + } +}