I’m trying to setup a home automation system to publish events. Since it runs C code, it can’t access the API via JavaScript or the CLI. But it can certainly make REST calls.
tcp_client particle_cloud;
push publish
{
socketDisconnectClient(particle_cloud);
socketConnectClient(particle_cloud, "api.particle.io", 443, 0);
}
socketConnect particle_cloud
{
makestring(request, "POST /v1/devices/events HTTP/1.1\nname: %s\nprivate: true\naccess_token: %s\n\n", event_name, access_token);
socketSend(particle_cloud, request);
}
When the automation system receives sees the “publish” join is pushed, it opens a connection with api.particle.io on port 443 (https). Once the connection is made, it sends the POST request.
Anyone familiar with REST see any obvious things I’m missing?