Page 1 of 1

How to do an HTTP push? **solved**

Posted: Tue Nov 05, 2013 1:19 pm
by Medor
Would a good soul please explain how meteobridge can push data through HTTP ?

Let's that I have a server where I want to see the meteobridge data, named http://www.myserver.com, and there is a file meteo.php at the document root, which would contain something like echo $_GET["temp"].

Let's say that on the meteobridge, in "Push Services" / "Individual HTTP Upload" I have entered the URL http://www.myserver.com/meteo.php?temp=[th0temp-act], with a 1 minute interval.
If I understand the process, meteobridge will then request the page meteo.php from myserver.com every minute ? But how would that push any data to myserver.com ?

Something totally escapes me... :?:

Re: How to do an HTTP push ?

Posted: Tue Nov 05, 2013 5:01 pm
by wvdkuil
Medor wrote:Would a good soul please explain how meteobridge can push data through HTTP ?

Let's that I have a server where I want to see the meteobridge data, named http://www.myserver.com, and there is a file meteo.php at the document root, which would contain something like echo $_GET["temp"].

Let's say that on the meteobridge, in "Push Services" / "Individual HTTP Upload" I have entered the URL http://www.myserver.com/meteo.php?temp=[th0temp-act], with a 1 minute interval.
If I understand the process, meteobridge will then request the page meteo.php from myserver.com every minute ? But how would that push any data to myserver.com ?

Something totally escapes me... :?:
Well, actuallly it does. Both Saratoga and the Leuven template use that procedure to load the realtime data. As do others.
The meteo.php from your example would NOT echo the information, as no one in the meteobridge is interested in that. The script meteo.php would process and store all the $_GET['fields'] into a file on the web-server, to be used later.
And the meteo.php will return an answer so that the meteobridge knows the http was processed correctly and display the green mark so that you can see that also.
Hope this clarifies thing, otherwise please feel free to ask more info.

Wim

Re: How to do an HTTP push ?

Posted: Tue Nov 05, 2013 10:05 pm
by admin
As Wim explained it needs a script on your HTTP server (can be php, or perl, or bash or ...) that reads the parameters from the URL and then does somehing usefull with it (like storing that into a mysql database, etc). There are plenty of code fragements around how to read URL parameters, as this is one of the typical tasks these script languages are used for.

Btw, this is exactly like most weather networks in the Internet get their data. Much faster, less protocol overhead than any FTP or alike.

Re: How to do an HTTP push ?

Posted: Sat Nov 09, 2013 11:26 pm
by Medor
Thx for both replies, I guess I am rusty... For those interested, such a meteo.php script in PHP would be something like:

Code: Select all

<?php
$fh = fopen('temperature.txt', 'a') or die();
$stringData = date("d/m/Y H:i").'temperature : '.htmlspecialchars($_GET["temp"])."\n";
fwrite($fh, $stringData);
fclose($fh);
?>
The meteobridge requests this script with the temperature temp as a parameter, so myserver reads this temp, stores it in a file temperature.txt, and then sends the blank page to the meteobridge, which just ignores it...

I guess I'd better have a look at the existing templates, if they give access to historical data.