How to read data sent by webhooks?

前端 未结 1 1217
耶瑟儿~
耶瑟儿~ 2021-01-06 20:14

I have the latest woocommerce plugin, and I have to set a webhook to one of my URL. But I am not able to read it in my $_REQUEST and nor in $input = file_get_contents(

相关标签:
1条回答
  • 2021-01-06 20:42
    $webhookContent = "";
    
    $webhook = fopen('php://input' , 'rb');
    while (!feof($webhook)) {
        $webhookContent .= fread($webhook, 4096);
    }
    fclose($webhook);
    mail('mail@yourdomain.com', 'test - hook', $webhookContent);
    

    This is all it took. It will send all the body to your email

    0 讨论(0)
提交回复
热议问题