你好我有这个工作的CURL帖请求我希望用guzzle重新编码。但我没有遇到400 Bad Request。任何人都能看到我做错了什么:
$response = $this->getHttpClient()->post(
'https://login.eveonline.com/oauth/token', [
'headers' => [
'Authorization' => 'Basic '.base64_encode(
env('EVEONLINE_CLIENT_ID').':'.env('EVEONLINE_CLIENT_SECRET')
)
],
'grant_type' => 'refresh_token',
'refresh_token' => $refresh_token,
]);
return json_decode($response->getBody()->getContents(), true);
/*
$c = curl_init();
$cver = curl_version();
$contact = 'postmaster@asite.net';
curl_setopt($c, CURLOPT_URL, 'https://login.eveonline.com/oauth/token');
curl_setopt($c, CURLOPT_USERAGENT, "asite/admin (curl/{$cver['version']}; {$contact})");
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($c, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_POSTFIELDS, http_build_query([
'grant_type' => 'refresh_token',
'refresh_token' => $refresh_token,
]));
curl_setopt($c, CURLOPT_HTTPHEADER, [ 'Authorization: Basic '.base64_encode(
env('EVEONLINE_CLIENT_ID').':'.env('EVEONLINE_CLIENT_SECRET')
) ]);
$rawjson = curl_exec($c);
return json_decode($rawjson, true);
*/
RESPONSE:
客户端错误:POST https://login.eveonline.com/oauth/token
导致400 Bad Request
响应:
{"错误":" invalid_request"," error_description":"未知grant_type"}
答案 0 :(得分:0)
已修复已为此造成的不便表示遗憾:
$response = $this->getHttpClient()->post(
'https://login.eveonline.com/oauth/token', [
'headers' => [
'Authorization' => 'Basic '.base64_encode(
env('EVEONLINE_CLIENT_ID').':'.env('EVEONLINE_CLIENT_SECRET')
)
],
'json' => [
'grant_type' => 'refresh_token',
'refresh_token' => $refresh_token,
]
]);