The service sends JSON via webhook. It is necessary that every time a webhook comes to my server from a service, a php script is launched that is written by this JSON, for example, to a txt file. How can this be done? I don’t understand where to set up sending webhook to port 80, which runs PHP or directly register the path to the script file? Please tell me which option will be correct. I will write the code myself, I am interested in how to implement this task.
2 answers
In the hook that will send json data, you need to specify the address of the script that will process the action (save to a txt file).
The address of the script is the url of the page, say http://mysite.ru:8080/folder/save_json.php
Some parts of the url can be omitted. For example, if you have a web server on port 80, you can specify the url simply as http://mysite.ru/folder/save_json.php
PS A well-worded question is half the answer. Look at the title of your question, it in fact does not reflect your question very well. The heading has the word "file", it is not needed there: it does not appear in your question or in the answer. You have a question (the way I read it and answered to it) is "How to specify the address of the PHP page that processes the json request."
Some formulations of the question are incorrect. PHP can not be run on port 80, on port 80 a web server can be run (iis, apache, nginx etc), which processes requests coming via the http (s) protocol. And already the web server can call PHP for some requests (for example, for those requests where the request ends in .php or .php5).
I honestly did not understand what you mean by this "directly prescribe the path to the script file?".
If the service from which the webhook comes has the ability to write to the file, then don’t have to pull your server with the script once again. If not, then there are no options. PHP code file_put_content json stroku. The only thing you have to check is json for validity. Json is a text format