Hello, I am trying to do this little program but after two days I dont seem to be able to get anywhere.
I want to be able to call a URL pointing to a file in my server which will simply return the date as this...
#201209101314%
just with a php like this
<?
echo "#" . time() . "%"
?>
I would like to read that answer form the server and break it into different variables "year" "month" "day" "hour" "minute" seconds" in order to then set the time in a RTC clock
// Set the RTC
RTC.adjust(DateTime(2012, 1, day, hour, mins, sec));
DateTime now = RTC.now();
Problem is I cant read the answer back.
I thing it has something to do with calling the URL.
My website is in a Godaddy server and I normally set the IP address
IPAddress server(188,121,46,128); // Goddady
and then call to my URL
GET http://mywebsite.com/arduino/clock.php
however although it says it connects, it does not answer anything.
The server name and http:// are NOT part of the GET request. Since you are not using your own domain, you will need to add a
Host: yourDomainName
record after the GET request.
Hello Paul and as always, thank you so much for your help.
Please let me ask a further clarification.
Why do we need this...
IPAddress server(188,121,46,128); // Goddady
If afterwards we are pointing to the specific URL by adding what you said of HOST
Should I therefore modify my GET request like this?
// if you get a connection, report back via serial:
if (client.connect(server, 80)) {
Serial.println("connected");
// Make a HTTP request:
client.println("GET /arduino/clock.php HTTP/1.0");
client.println("Host: www.mydomainingodaddy.com");
client.println();
}
else {
// kf you didn't get a connection to the server:
Serial.println("connection failed");
}
I belief I tried this code before but could not read the answer back from the page. maybe something with the client.available issue.
I have a project running for 2 years which is doing
If afterwards we are pointing to the specific URL by adding what you said of HOST
The IP address defines a piece of hardware. The Host: line defines which domain to access when the machine hosts more than one domain. If you set up your own server, hosting just one domain, you would not need to specify both. But, since you are using a hosting service that serves up lots of domains, you do.
Should I therefore modify my GET request like this?
I think that is correct, except that the Host line does not have the www. bit up front.
Now I understand the IP versus the URL that I did not understand before. I even tried to look it but could not find such a straight forward and easy explanation. Now it makes sense.
I will continue investigating cause i am doing this to my website file in the godaddy server but does not respond.
//using this ip at the beginning of the code
IPAddress server(188,121,46,128); // Goddady
and in the loop...
client.println("GET /arduino/clock.php HTTP/1.0");
client.println("Host: mydomainingodaddy.com");
client.println();