Php Bigcommerce API-创建Webhook-标头无效
我在这个项目上迈出了一小步。现在创建并注册一个webhook。我得到的答复如下: 400-标题无效 我尝试了以下代码:Php Bigcommerce API-创建Webhook-标头无效,php,bigcommerce,webhooks,guzzle,Php,Bigcommerce,Webhooks,Guzzle,我在这个项目上迈出了一小步。现在创建并注册一个webhook。我得到的答复如下: 400-标题无效 我尝试了以下代码: // Send a request to register a web hook $http2 = new Client('https://api.bigcommerce.com', array( 'request.options' => array( 'exceptions' => false, 'headers' =>
// 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>';
//发送注册web钩子的请求
$http2=新客户端('https://api.bigcommerce.com,数组(
'请求.选项'=>数组(
“异常”=>false,
'headers'=>数组(
“X-Auth-Client”=>$Client\u id,
“X-Auth-Token”=>$access\u Token,
'内容类型'=>'应用程序/json',
“X-Custom-Auth-Header”=>$access\u令牌,
)
)
));
$request=$http2->post('/'.$store\u hash.'/v2/hooks',null,数组(
“范围”=>“存储/订单/*”,
'目的地'=>'https://example.com/process_order.php',
“是否处于活动状态”=>true
));
$response=$request->send();
$body=$response->getBody(true);
var_dump($车身);
回显“状态代码:”$响应->getStatusCode() ",;
。。。及
// 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>';
//发送注册web钩子的请求
$http2=新客户端('https://api.bigcommerce.com,数组(
'请求.选项'=>数组(
“异常”=>false,
'headers'=>数组(
“X-Auth-Client”=>$Client\u id,
“X-Auth-Token”=>$access\u Token,
'内容类型'=>'应用程序/json',
)
)
));
$request=$http2->post('/'.$store\u hash.'/v2/hooks',null,数组(
“范围”=>“存储/订单/*”,
'headers'=>数组(
“X-Custom-Auth-Header”=>$access\u令牌,
),
'目的地'=>'https://example.com/process_order.php',
“是否处于活动状态”=>true
));
$response=$request->send();
$body=$response->getBody(true);
var_dump($车身);
回显“状态代码:”$响应->getStatusCode() ",;
我正在处理以下文档:
然而,我似乎也不知道什么是{secret\u auth\u password}?文档没有解释这一点。我正在发送客户端ID和客户端头作为头的一部分
仍然获取无效的头作为响应
我在用口香糖
有谁能在这方面帮助我吗?经过多次尝试,我终于找出了我做错的地方 答:以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();
我在我们的自定义脚本中使用了这段代码,但出现了错误---致命错误:未捕获错误:在中找不到类“Client”