Post to webpage

I’m trying to post imp data via Agent to custom webpage. Web page containing info looking similar like server.log(), just clear data. I can write to txt file on the server, but cannot get it on webpage. Any ideas?

Your webpage needs to be .php instead of .html

Then, on that page you need to either include the .txt file or load it into a array and process it however you need to data displayed.

Can you post an example of the .txt file?

I can post to txt file on server via php from imp. I think that I need to reload webpage every time when new data arrive. Page reload on constant time intervals can be easy implemented in to code. I don’t know how to reload when new data arrive to txt file.

You could reload on a fixed interval, or you could use ajax on a timer to let php check if the file changed, and if it did reload the page.

Or you could use websockets (advanced) to have live updates the second the imp agent sends data :slight_smile:

The imp can upload data to your website (.txt file), but there is no way the imp, or anything else, can command your browser to refresh. The browser is client-side, so you would be utilizing javascripting or AJAX, which is a combination of javascripting and PHP.

What is the timeframe you need for your data? 1 second, 10 seconds, 1 minute? And how important is it that your browser keeps a refreshed screen of data?

as mlseim has stated, the web page must initiate this request to the agent via http GET. You can get it to make repeated requests using the method setInterval() in your web page.

I am not saying I have all the best methods, but you can get an example of a fully functioning web page - agent - device here:

oven project

Scroll to the very bottom of the page for links to the code.

There is also a related thread here

and it is the place I started from.

Before we had the agents I had a web app that relied on PHP to update text files and a web app to read them. It worked - sort of. Now that we have agents you can skip the PHP and go directly from the web page. I still have a PHP script that runs but only to create a log file.

@mjkuwp94
Thanks! Oven Project is great, very handy and modifications can have many applications. I must check out how to exclude PHP txt file, as you say.