Guzzle HTTP 客户端和 Shopify 访问令牌异常
Guzzle HTTP Client and Shopify access token exception
我在 Shopify 中尝试用临时代码交换访问令牌时收到 Client error: POST https://testing-shop.myshopify.com/admin/oauth/access_token resulted in a 400 Bad Request
。我正在使用最新版本的 Guzzle HTTP 客户端和 Chrome、Windows 8.1。更奇葩的是,之前还管用
$client = new Client();
try{
$response = $client->request(
'POST',
"https://{$store}/admin/oauth/access_token",
[
'form_params' => [
'client_id' => $api_key,
'client_secret' => $secret_key,
'code' => $query['code']
]
]
);
}catch(Exception $e){
var_dump($e);
}
我还检查了所有变量 ($api_key, $secret_key
)...它们很好,这意味着它们具有价值。我错过的问题可能是什么? TIA
编辑:
原来是注册web hook时的问题
$response = $client->request(
'POST',
"https://{$store}/admin/webhooks.json",
[
'webhook' => [
'topic' => 'app/uninstalled',
'address' => 'http://example.com/shopify/uninstall',
'format' => 'json'
]
]
);
这段代码导致了错误,但我不知道为什么。
我想我明白了。它适合工作然后停止工作:
After July 1st 2018, apps will be required to use HTTPS webhook addresses.
我在 Shopify 中尝试用临时代码交换访问令牌时收到 Client error: POST https://testing-shop.myshopify.com/admin/oauth/access_token resulted in a 400 Bad Request
。我正在使用最新版本的 Guzzle HTTP 客户端和 Chrome、Windows 8.1。更奇葩的是,之前还管用
$client = new Client();
try{
$response = $client->request(
'POST',
"https://{$store}/admin/oauth/access_token",
[
'form_params' => [
'client_id' => $api_key,
'client_secret' => $secret_key,
'code' => $query['code']
]
]
);
}catch(Exception $e){
var_dump($e);
}
我还检查了所有变量 ($api_key, $secret_key
)...它们很好,这意味着它们具有价值。我错过的问题可能是什么? TIA
编辑:
原来是注册web hook时的问题
$response = $client->request(
'POST',
"https://{$store}/admin/webhooks.json",
[
'webhook' => [
'topic' => 'app/uninstalled',
'address' => 'http://example.com/shopify/uninstall',
'format' => 'json'
]
]
);
这段代码导致了错误,但我不知道为什么。
我想我明白了。它适合工作然后停止工作:
After July 1st 2018, apps will be required to use HTTPS webhook addresses.