我有一个通道应用程序,可以从服务器接收数据。在webhook部分中,我添加了一个通过webhooks发送数据的网址。出于某种原因,推杆似乎无法访问该网址
<?php
// environmental variable must be set
$app_secret = getenv('xxxxxxxxxxxxxxxx');
$app_key = $_SERVER['xxxxxxxxxxxxx'];
$webhook_signature = $_SERVER ['HTTP_X_PUSHER_SIGNATURE'];
$body = file_get_contents('php://input');
$expected_signature = hash_hmac( 'sha256', $body, $app_secret, false );
if($webhook_signature == $expected_signature) {
// decode as associative array
$payload = json_decode( $body, true );
foreach($payload['events'] as &$event) {
// do something with the event
$fp .= file_put_contents( 'event.log', $event);
}
header("Status: 200 OK");
}
else {
$fp .= file_put_contents( 'error.log', 'test');
header("Status: 401 Not authenticated");
}
?>