I've created an Arduino Ethernet sketch, such that on a button push, it requests a URL (http://myserver.lan/sensors/garage.php). My thought was that I could then use this PHP script to pull a separate URL that I can update without having to reflash the Arduino. This separate URL drives certain home automation events.
I tried the following in garage.php:
<?php
$homepage = file_get_contents('http://myserver.lan/test/');
?>
This works for my browser, but not for the Arduino board. The logs for the two are as follows:
Arduino:
192.168.2.50 - - [21/Mar/2013:13:43:58 -0400] "GET /sensors/garage.php HTTP/1.1" 400 515 "-" "-"
Safari:
192.168.2.3 - - [21/Mar/2013:13:43:28 -0400] "GET /test/ HTTP/1.0" 200 2235 "-" "-"
192.168.2.65 - - [21/Mar/2013:13:43:28 -0400] "GET /sensors/garage.php HTTP/1.1" 200 293 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/536.28.10 (KHTML, like Gecko) Version/6.0.3 Safari/536.28.10"
For completeness, here is the code sample from my Arduino sketch:
EthernetClient client;
if (client.connect(rackserver, 80)) {
client.println("GET /sensors/garage.php HTTP/1.1");
}
client.stop();
How can I fix the PHP script? I'm hoping to accomplish this without reflashing my Arduino.