PHP脚本坐下等待捕获Webhook

I am wanting to capture a Webhook in PHP. I dont know when the webhook will come through so I have to keep the site actively looping until it does. The response comes through in a JSON array, so I want to display this to see if it works if possible.

Could someone please send through some sample PHP to do this?

I tried it like this and I kept getting errors after 30 seconds

<?php
$webhookContent = "";

do {
$webhook = fopen('php://input' , 'rb');
while (!feof($webhook)) {
    $webhookContent .= fread($webhook, 4096);
}
fclose($webhook);

error_log($webhookContent);

} while ($webhookContent == "");

echo $webhook;
?>

The error I got was

Fatal error: Maximum execution time of 30 seconds exceeded in /home/passames/public_html/hook/hook.php on line 11

I also tried to echo $webhookcontent with no luck.

Hope someone can help.