So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By AndrewCarnell
#82440 I have a script which sends a message to php page, when I connect via my mobile phone all works fine but when I connect via the office UnFi network the GET message never leaves the building. Any ideas please.

#include <Arduino.h>
#include <EEPROM.h>
#define USE_SERIAL Serial
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>


sprintf(thingspeak_string, "http://www.xxxxxxxxxxxx.php?sensor_id=1&flow=1&key=xxxxxxxxxxxxx&", 5000, "/");
//String sent to ThingSpeak server.
// http.begin(thingspeak_string);
http.begin(cli, thingspeak_string);
http.addHeader("Content-Type", "text/plain");

//Send HTTP Header
int httpCode = http.GET();

Serial.println(thingspeak_string);



SOLVED - sort of!

Sending the message as a POST works fine ???

//Post Data
String postData;
postData = "xxxxxxxxx=1&xxxxxxxx=1&xxxxxx=xxxxxxxxxx";

http.begin("http://www.xxxxxxxxxxxxxxxxx.php"); //Specify request destination
http.addHeader("Content-Type", "application/x-www-form-urlencoded"); //Specify content-type header

int httpCode = http.POST(postData); //Send the request
String payload = http.getString(); //Get the response payload

Serial.println(httpCode); //Print HTTP return code
Serial.println(payload); //Print request response payload

http.end(); //Close connection