Hi,
I wrote following sample firmware to get data from server,
if I directly hit the URL I get the data
http://toptalkback.com/api/services/app/Septic/GetSchedule?serial=4c0030001851373237343331
however it does not return any data in firmware code
TCPClient client;
String host = "toptalkback.com";
const int serverPort = 80;
String DownloadJson(String url){
String output;
if(client.connect(host, serverPort)) {
client.println("GET "+url+" HTTP/1.0");
client.println("Host: " + host);
client.printlnf("Content-Length: %d", 2);
client.println("Content-Type: application/json");
client.println();
client.flush();
delay(5000);
while(client.available()) {
char c = client.read();
output = output + c;
}
}
return output;
}
void setup() {
}
void loop() {
String strHours = DownloadJson("/api/services/app/Septic/GetSchedule?serial=4c0030001851373237343331");
Particle.publish("arr", strHours);
}
help appreciated
-NJ