jskidd3 jskidd3 - 1 year ago 128
PHP Question

How to use PHP to take raw POST data and save to file?

I'm working with an interface standard for exchanging information about the planned, current or projected performance of real-time public transport operations between different computer systems. This standard is called SIRI.

To cut a long story short, I've made a subscription with a service that sends me XML data through this interface every 30 seconds. From what I've highlighted in the red box below, it states that http is used to send this data which is what I would have preferred.

I need to create a PHP file that can listen for this HTTP data and then save it to a file (overwriting the previous file every 30 seconds).

I've done some preliminary research into how I can go about doing this and I've done a little reading on:




If anyone can help me come up with a PHP solution to doing this with one of these methods or a better one I'd really appreciate it.

enter image description here

Answer Source

All that really needs to be done is:

file_put_contents("outputfile.txt", file_get_contents("php://input"));

Apache will deal with managing the incoming requests.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download