Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years, 5 months ago.
Pushingbox API using lpc1768
Hi, I am trying to launch a notification to the pushingbox server using ESP8266, I have tried converting code from Arduino but I cannot produce the client.print and client.stop in the mbed, How should I replace it with to create the similar result?
arduino code
String postStr = "devid=";
postStr += String(deviceId);
postStr += "&message_parameter=";
postStr += String(message);
postStr += "\r\n\r\n";
Serial.println("- sending data...");
client.print("POST /pushingbox HTTP/1.1\n");
client.print("Host: api.pushingbox.com\n");
client.print("Connection: close\n");
client.print("Content-Type: application/x-www-form-urlencoded\n");
client.print("Content-Length: ");
client.print(postStr.length());
client.print("\n\n");
client.print(postStr);
client.stop();
Trying on mbed code
string postStr = "devid=";
postStr += string(deviceId);
postStr += "&message_parameter=";
postStr += string(message);
postStr += "\r\n\r\n";
strcpy(webbuff, "POST /pushingbox HTTP/1.1\n");
strcat(webbuff, "Host: api.pushingbox.com");
strcat(webbuff, "Connection: close\n");
strcat(webbuff, "Content-Type: application/x-www-form-urlencoded\n");
strcat(webbuff, "Content-Length: ");
strcat(webbuff, "postStr.length()");
strcat(webbuff, "\n\n");
strcat(webbuff, "postStr");
strcpy(snd,"AT+CIPSEND=1,2000\r\n");
SendCMD();
timeout=5;
getreply();
pc.printf(buf);
Any helps would be appreciated. Thanks.