Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By Ebolisa
#88246 Hi,

Do to ISP's security, I cannot connect directly to the DB Server so I need to send data using API through a PHP file which in turn stores the data into the DB Server.

The PHP file works fine via html form or via python codes so, I'm pretty sure the issue I'm having is with my code.

The error received when the code is executed is "unable to connect". I can only assume that it's an SSL connection issue as the ISP web server needs a secure connection.

How do I do that?

Code: Select allconst char* dbServerName = "";

void db_send() {
  //Check WiFi connection status
  if (WiFi.status() == WL_CONNECTED) {
    HTTPClient http;

    // Your Domain name with URL path or IP address with path
    // Specify content-type header
    http.addHeader("Content-Type", "application/x-www-form-urlencoded");

    //concat data to be sent
    String httpRequestData = "api_key=" + apiKeyValue +
                             "&temp=" + String(t) +
                             "&humidity=" + String(h) +
                             "&board=" + board +
   //let's see what is being sent
    Serial.print("httpRequestData: "); Serial.println(httpRequestData);

    // Send HTTP POST request
    int httpResponseCode = http.POST(httpRequestData);

    if (httpResponseCode > 0) {
      Serial.print("HTTP Response code: "); Serial.println(httpResponseCode);
    else {
      Serial.print("Error code: "); Serial.println(httpResponseCode); // if -1 connection failed!!

    // Free resources
  else {
    Serial.println("WiFi Disconnected");
User avatar
By Bonzo
#88247 Have a non https sub domain for just this php form or add the SSL finger print to http.begin(dbServerName);

If like my hosts the security certificate changes every year you would have to update you code with the new finger print every year.

There was a similar post to this last week and the OP came back with an answer - try seaching.
User avatar
By Bonzo
Ebolisa wrote:Ok, will try to talk to ISP for a non SSL subdomail. Thanks.

That is the way I do it.

If you have cpanel you can setup a sub domain yourself; from memory it is quite easy.