0
你好,我有這個工作CURL發佈請求我希望用guzzle重新編碼。但我在400壞請求上失敗。任何人都看到我在做什麼錯:需要幫助將一個PHP CURL腳本轉換爲垃圾
$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 = '[email protected]';
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);
*/
迴應: 客戶端錯誤:POST https://login.eveonline.com/oauth/token
導致了400 Bad Request
響應: { 「錯誤」: 「INVALID_REQUEST」, 「ERROR_DESCRIPTION」: 「未知grant_type」}
什麼版本的Guzzle? – ceejayoz
https://github.com/guzzle/psr7 1.3.1發佈 –