如何接收Shopify Webhook?

问题描述 投票:0回答:1

下面是我的代码。

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。因此,这是我的代码,但未收到任何响应

webhooks shopify-app
1个回答
0
投票

我知道这是一个迟来的答案。但是可能对将来登陆这里的未来用户有所帮助。您忘记将从response中获得的uninstall webhook保存到某个地方。考虑将response保存到文件。这是要保存的php代码。保存响应后,您可以随后阅读或进行处理。

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.