我正在尝试在安装shopify应用程序时创建webhook(订单/创建),但我无法使其正常工作。在尝试创建webhook时,我收到错误“Unprocessable Entity”。以下是我目前使用的代码。你能帮我修一下这个错误。
if (isset($_GET['code'])) {
$shopifyClient = new ShopifyClient($_GET['shop'], "", API_KEY, SECRET);
session_unset();
$_SESSION['token'] = $shopifyClient->getAccessToken($_GET['code']);
if ($_SESSION['token'] != '')
$_SESSION['shop'] = $_GET['shop'];
$shopifyClient = new ShopifyClient($_GET['shop'], $_SESSION['token'], API_KEY, SECRET);
$charge = array("webhook"=>array("topic"=>"orders/create","address"=>"http://localhost/xxxxx/test.php","format"=>"json"));
try
{
$webhooks = $shopifyClient->call('POST','/admin/webhooks.json',$charge);
} catch(Exception $e){
//do something with the Exception
echo $e->getMessage();
exit;
}
header("Location: http://localhost/xxxxx/index.php");
exit;
}
答案 0 :(得分:1)
可能不是你的主要问题(可能是这样),但Shopify不会添加localhost webhook。尝试https://forwardhq.com/之类的内容来测试应用中的webhook,或http://requestb.in/如果您只想检查它们。