'TradinView problem with reading webhooks and running the page script

I have the following problem: In the TradingView application, I have alarms set and sending them via the URL Webhook to the address http://mpietraszewski.cba.pl/trade.php. Ultimately, I would like the script to be executed on the website after receiving the alert (saving to the sql database). Unfortunately, the methods I have tested do not bring any results. When you refresh the page manually, a new record is created in the database, but nothing happens on subsequent alerts from TradingView. The tested methods are:

<? php 
if ($ _SERVER ['REQUEST_METHOD'] == 'POST') {
    // fetch RAW input
    $ json = file_get_contents ('php: // input');

    // decode json
    $ object = json_decode ($ json);

    // expecting valid json
    if (json_last_error ()! == JSON_ERROR_NONE) {
        die (header ('HTTP / 1.0 415 Unsupported Media Type'));
    }

    / **
     * Do something with object, structure will be like:
     * $ object-> accountId
     * $ object-> details-> items [0] ['contactName']
     * /
    // dump to file so you can see
    file_put_contents ('callback.test.txt', print_r ($ object, true));}

With the example message: "{" text ":" BTCUSD greater than 9000 "}"

Rigid GET method: "example.com/?action=BUY" as Webhook.

By the POST method.

Thank you in advance for your help.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source