Bigcommerce API - 创建 Webhooks - 无效 Header

Bigcommerce API - Creating Webhooks - Invalid Header

我正在为我正在从事的这个项目做一些小步骤。现在创建并注册一个 webhook。我收到以下回复:

400 - 无效 Header

我试过以下代码:

// Send a request to register a web hook
$http2 = new Client('https://api.bigcommerce.com', array(
    'request.options' => array(
        'exceptions' => false,
        'headers' => array(
            'X-Auth-Client' => $client_id,
            'X-Auth-Token'  => $access_token,
            'Content-Type'  => 'application/json',
            'X-Custom-Auth-Header' => $access_token,
        )
    )
));
$request = $http2->post('/'.$store_hash.'/v2/hooks', null, array(
    'scope'         => 'store/order/*',
    'destination'   => 'https://example.com/process_order.php',
    'is_active'     => true
));
$response = $request->send();
$body = $response->getBody(true);
var_dump($body);

echo '<p>Status Code: ' .  $response->getStatusCode() . '</p>';

...和

// Send a request to register a web hook
$http2 = new Client('https://api.bigcommerce.com', array(
    'request.options' => array(
        'exceptions' => false,
        'headers' => array(
            'X-Auth-Client' => $client_id,
            'X-Auth-Token'  => $access_token,
            'Content-Type'  => 'application/json',
        )
    )
));
$request = $http2->post('/'.$store_hash.'/v2/hooks', null, array(
    'scope'         => 'store/order/*',
    'headers'       => array(
        'X-Custom-Auth-Header' => $access_token,
    ),
    'destination'   => 'https://example.com/process_order.php',
    'is_active'     => true
));
$response = $request->send();
$body = $response->getBody(true);
var_dump($body);

echo '<p>Status Code: ' .  $response->getStatusCode() . '</p>';

我正在处理这里的文档: https://developer.bigcommerce.com/api/stores/v2/webhooks#create-a-hook

但是,我似乎无法弄清楚 {secret_auth_password} 是什么?文档没有对此进行解释。我也将客户端 ID 和客户端 Header 作为 headers 的一部分发送。

仍然收到无效 Header 作为响应。

我正在使用 Guzzle。

有人可以帮我解决这个问题吗?

经过无数次尝试,我终于弄清楚了我做错了什么。

答:以JSON格式发送数据。

解析代码:

// Send a request to register a web hook
$http3 = new Client('https://api.bigcommerce.com', array(
    'request.options' => array(
        'exceptions' => false,
        'headers' => array(
            'X-Auth-Client' => $client_id,
            'X-Auth-Token'  => $access_token,
            'Content-Type'  => 'application/json',
            'Accept'        => 'application/json',
        )
    )
));
$request = $http3->post('/'.$store_hash.'/v2/hooks', null, json_encode(array(
    'scope'         => 'store/order/statusUpdated',
    'destination'   => 'https://example.com/process_order.php',
)));
$response = $request->send();