【发布时间】:2019-01-23 09:25:50
【问题描述】:
下面是我的代码。
define('SHOPIFY_APP_SECRET', 'xxxxxxxxxx');
function verify_webhook($data, $hmac_header)
{
$calculated_hmac = base64_encode(hash_hmac('sha256', $data, SHOPIFY_APP_SECRET, true));
return hash_equals($hmac_header, $calculated_hmac);
}
$hmac_header = $_SERVER['HTTP_X_SHOPIFY_HMAC_SHA256'];
$data = file_get_contents('php://input');
$verified = verify_webhook($data, $hmac_header);
echo "<pre>";
print_r($data);
exit;
?>
我已经注册了应用程序/已卸载的 webhook。 所以这是我的代码,但没有收到任何响应
【问题讨论】:
-
如果您没有收到 webhook 请求(不是响应),那么您的签名验证代码不会提供任何帮助来确定问题所在。有各种各样的问题可能会干扰获取请求。我建议您尝试 Shopify 社区论坛,因为他们非常擅长帮助人们解决 webhook 实施问题。
-
嘿,@dmulter 现在我收到了我的 webhook 的请求(而不是响应)。问题在于我的“SHOPIFY_APP_SECRET”谢谢您的回复。
标签: webhooks shopify-app