Php 在Codeigniter 4 base项目中尝试设置Coinbase Webhook时出现问题
我想添加一个webhook来验证和获取coinbase事件 这是我的webhook控制器Php 在Codeigniter 4 base项目中尝试设置Coinbase Webhook时出现问题,php,codeigniter-4,coinbase-php,Php,Codeigniter 4,Coinbase Php,我想添加一个webhook来验证和获取coinbase事件 这是我的webhook控制器 public function verifyCoinbase() { $secret = 'xxxxxxxxxxxxxxxxx'; $headerName = 'X-Cc-Webhook-Signature'; $headers = getallheaders(); $signraturHeader = isset($headers[$headerName]) ? $headers[$headerName
public function verifyCoinbase() {
$secret = 'xxxxxxxxxxxxxxxxx';
$headerName = 'X-Cc-Webhook-Signature';
$headers = getallheaders();
$signraturHeader = isset($headers[$headerName]) ? $headers[$headerName] : null;
$payload = trim(file_get_contents('php://input'));
try {
$event = Webhook::buildEvent($payload, $signraturHeader, $secret);
http_response_code(200);
echo sprintf('Successully verified event with id %s and type %s.', $event->id, $event->type);
} catch (\Exception $exception) {
http_response_code(400);
echo 'Error occured. ' . $exception->getMessage();
}
}
运行测试时,我收到一条错误消息,上面说
hash_equals():预期已知_字符串为字符串,给定null
试了三天。如果我能找到解决这个问题的办法,我将非常高兴。请帮忙 这个问题不是很清楚。您通常需要一个函数来验证接收到的webhook(带有事件)。文档应该指向如何验证webhook。错误是“hash_equals()”的结果为空,因此您可能没有正确计算哈希。