// Author : Sanjeev Kumar // Contact: sanjeev at outlook Dot in // This #include statement was automatically added by the Particle IDE. #include "HttpClient.h" unsigned int nextTime = 0; // Next time to contact the server HttpClient http; http_header_t headers[] = { { "Authorization", "Basic QWxhZGRpbjpPcGVuU2VzYW1l" }, { "Accept" , "*/*"}, { NULL, NULL } // NOTE: Always terminate headers will NULL }; http_request_t request; http_response_t response; void setup() { Serial.begin(9600); } void loop() { if (nextTime > millis()) { return; } request.hostname = "localhost"; request.port = 80; request.path = "/flaskapp"; http.get(request, response, headers); Particle.publish("Response Status: ", String::format("%3i",response.status)); Particle.publish("Request body: ", response.body); nextTime = millis() + 10000; }
https://gitlab.com/particle-photon/httpclientexample