[Solved] how i can read a php page?
hi guys!
i have virtual server create string need read arduino.
i made php page , write string correctly when access broser.
it php page
i change webclient example
and error.
connecting...
connected
<!doctype html public "-//ietf//dtd html 2.0//en">
<html><head>
<title>400 bad request</title>
</head><body>
<h1>bad request</h1>
<p>your browser sent request server not understand.<br />
</p>
<p>additionally, 404 not found
error encountered while trying use errordocument handle request.</p>
</body></html>
disconnecting.
thanks
i have virtual server create string need read arduino.
i made php page , write string correctly when access broser.
it php page
code: [select]
<?php
$fp = fopen("cambiorelojes.txt", "r");
$linea = fgets($fp);
fclose($fp);
echo "$linea";
?>
i change webclient example
code: [select]
#include <spi.h>
#include <ethernet.h>
byte mac[] = { 0xde, 0xad, 0xbe, 0xef, 0xfe, 0xed };
char server[] = "www.domain.com"; // name address google (using dns)
ipaddress ip(192,168,1,38);
ethernetclient client;
void setup() {
serial.begin(9600);
while (!serial) {
;
}
if (ethernet.begin(mac) == 0) {
serial.println("failed configure ethernet using dhcp");
ethernet.begin(mac, ip);
}
delay(1000);
serial.println("connecting...");
if (client.connect(server, 80)) {
serial.println("connected");
client.println("get www.domain.com/relojes/leercambio.php");
client.println("host: www.domain.com");
client.println("connection: close");
client.println();
}
else {
serial.println("connection failed");
}
}
void loop()
{
if (client.available()) {
char c = client.read();
serial.print(c);
}
// if server's disconnected, stop client:
if (!client.connected()) {
serial.println();
serial.println("disconnecting.");
client.stop();
while(true);
}
}
and error.
connecting...
connected
<!doctype html public "-//ietf//dtd html 2.0//en">
<html><head>
<title>400 bad request</title>
</head><body>
<h1>bad request</h1>
<p>your browser sent request server not understand.<br />
</p>
<p>additionally, 404 not found
error encountered while trying use errordocument handle request.</p>
</body></html>
disconnecting.
thanks
Arduino Forum > Using Arduino > Networking, Protocols, and Devices (Moderator: fabioc84) > [Solved] how i can read a php page?
arduino
Comments
Post a Comment