WooCommerce REST API webhooks, Как перехватить ответную реакцию? - PullRequest
0 голосов
/ 30 марта 2020

Я создаю хук с использованием REST API и даю 'delivery_url`, и он работает нормально и создает веб-хуки, как и ожидалось. Но всякий раз, когда я обновляю заказ, он ничего не отправляет на delivery_url, или, может быть, я не знаю, как получить ответ от woocommerce. Код, который я использую для получения ответа:

$homepage = @file_get_contents("php://input");

Хотя в Woocommerce> Status> log я получаю журнал обновления моего заказа

    2020-03-30T07:40:58+00:00 INFO Array
(
    [Webhook Delivery] => Array
        (
            [Delivery ID] => 76911035b958d761689abc0817188031
            [Date] => Mar 30, 2020 @ 7:40
            [URL] => https://www.dev.site.net/ccwoocommerce/webhooks.php
            [Duration] => 0.45591
            [Request] => Array
                (
                    [Method] => POST
                    [Headers] => Array
                        (
                            [User-Agent] => WooCommerce/4.0.1 Hookshot (WordPress/5.3.2)
                            [Content-Type] => application/json
                            [X-WC-Webhook-Source] => https://website.com/
                            [X-WC-Webhook-Topic] => order.updated
                            [X-WC-Webhook-Resource] => order
                            [X-WC-Webhook-Event] => updated
                            [X-WC-Webhook-Signature] => MVXYSG7cR5*****
                            [X-WC-Webhook-ID] => 223
                            [X-WC-Webhook-Delivery-ID] => *******
                        )

                )

            [Body] => Webhook body is not logged unless WP_DEBUG mode is turned on. This is to avoid the storing of personal data in the logs.
            [Response] => Array
                (
                    [Code] => 302
                    [Message] => Found
                    [Headers] => Requests_Utility_CaseInsensitiveDictionary Object
                        (
                            [data:protected] => Array
                                (
                                    [date] => Mon, 30 Mar 2020 07:40:58 GMT
                                    [server] => Apache
                                    [location] => /user
                                    [cache-control] => max-age=300
                                    [expires] => Mon, 30 Mar 2020 07:45:58 GMT
                                    [x-endurance-cache-level] => 0
                                    [content-type] => text/html; charset=UTF-8
                                )

                        )

                    [Body] => Webhook body is not logged unless WP_DEBUG mode is turned on. This is to avoid the storing of personal data in the logs.
                )

        )

)
...