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

All about the standard Meteobridge devices based on mobile routers from TP-Link, D-Link, ASUS

Moderator: Mattk

Post Reply
Medor
Junior Boarder
Junior Boarder
Posts: 31
Joined: Sun Apr 21, 2013 10:00 pm

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

Post 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... :?:
User avatar
wvdkuil
Platinum Boarder
Platinum Boarder
Posts: 606
Joined: Sun Jul 24, 2011 8:00 pm
Location: Belgium
Contact:

Re: How to do an HTTP push ?

Post 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
User avatar
admin
Platinum Boarder
Platinum Boarder
Posts: 7874
Joined: Mon Oct 01, 2007 10:51 pm

Re: How to do an HTTP push ?

Post 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.
Medor
Junior Boarder
Junior Boarder
Posts: 31
Joined: Sun Apr 21, 2013 10:00 pm

Re: How to do an HTTP push ?

Post 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.
Post Reply