0
我有一個問題將此代碼翻譯爲Guzzle(Guzzle3和Guzzle4 = GuzzleHttp)。正如你可以看到它使用BASIC AUTH,相信我我嘗試了很多組合,任何想法?感謝Guzzle 3/4 - 無法POST
function get_auth($params) {
$client_id = 'name';
$secret = 'WEirdCombINationOfCharacters';
$opts[CURLOPT_POSTFIELDS] = http_build_query($params, null, '&');
$opts[CURLOPT_RETURNTRANSFER] = true;
$opts[CURLOPT_FRESH_CONNECT] = true;
$opts[CURLOPT_USERPWD] = "$client_id:$secret";
$opts[CURLOPT_HTTPAUTH] = CURLAUTH_BASIC;
$opts[CURLOPT_URL] = 'https://address.com/oauth/token';
$ch = curl_init();
curl_setopt_array($ch, $opts);
$result = curl_exec($ch);
curl_close($ch);
$result_object = json_decode($result);
if($result_object->error_description) trigger_vg_error($result_object->error_description);
return $result_object;
}