0

I am trying to get my Arduino With Ethernet Shield to call a PHP script. The domain is like this: sub.domain.com and the script I want to call is like this script.php?value1=value&somevalue2=somevalue&value3=somevalue.

I tried making it work with the example that comes with the Arduino library, but I was not successful.

EthernetClient ethClient;
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xEF };
char server[] = "sub.domain.com";

void setup() {
    [...]
    if (Ethernet.begin(mac) == 0) {
        Serial.println("Failed to configure Ethernet using DHCP");
    }

    [...]
}

void loop() {   
    [...] 
  if (ethClient.connect(server, 80)) {
    Serial.println("Conected to: " + String(server));
    String getUrl = "/script.php?location=" + String(LOCATIONID) + "&sc=2&feedP=" + String(feedBar) + "&returnP=" + String(returnBar) ;
    Serial.println(getUrl);
    // Make a HTTP request:
    ethClient.println("GET " + getUrl + " HTTP/1.1");
    ethClient.println("Host: sub.domain.com");
    ethClient.println("Connection: close");
    ethClient.println();
  } else {
    // if you didn't get a connection to the server:
    Serial.println("Could not connect to: " + String(server));
  }

if (ethClient.available()) {
  char c = ethClient.read();
  Serial.println("Respons: ");
  Serial.print(c);
}
    [...]
}
user3459805
  • 141
  • 1
  • 12

1 Answers1

-1

It works when not using a subdomain.

user3459805
  • 141
  • 1
  • 12