shopify无法处理的实体

Nau*_*lid 5 php shopify

在安装应用程序时运行此代码时,我收到无法处理的实体状态代码 422 错误。 这是代码

$sc = new ShopifyClient($_SESSION['shop'], $_SESSION['token'], $api_key, $secret);
$charge = array
(
    "webhooks"=> array
    (
        "topic"=>"orders/create",
        "address"=>"http://www.abc123no.com/nomi/s.php?key=123456789",
        "format"=>"json"
    )
);


try 
{
            $webhooks = $sc->call('POST','/admin/webhooks.json',$charge);
}
catch (ShopifyApiException $e)
{
    var_dump($e->getResponseHeaders());
}
Run Code Online (Sandbox Code Playgroud)

Dyl*_*ith 3

错误代码 422 表示验证错误。响应的正文将描述错误以帮助您调试应用程序。

例如,响应可能是:{"errors":{"address":["for this topic has already been taken"]}}

您的错误似乎是由于使用了错误的请求格式造成的。创建端点不采用 webhook 数组,您应该使用单数“webhook”作为顶级密钥。

Webhook API文档具有正确的请求正文格式。