Php Guzzle 3/4-无法发布
我在将这段代码翻译成Guzzle-Guzzle3和Guzzle4=GuzzleHttp时遇到问题。正如你所看到的,它使用基本的AUTH,相信我,我已经尝试了很多组合,有什么想法吗?谢谢Php Guzzle 3/4-无法发布,php,curl,guzzle,Php,Curl,Guzzle,我在将这段代码翻译成Guzzle-Guzzle3和Guzzle4=GuzzleHttp时遇到问题。正如你所看到的,它使用基本的AUTH,相信我,我已经尝试了很多组合,有什么想法吗?谢谢 function get_auth($params) { $client_id = 'name'; $secret = 'WEirdCombINationOfCharacters'; $opts[CURLOPT_POSTFIELDS] = http_build_query($params, null, '&a
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;
}
只需使用Guzzle 3 BASIC_AUTH留下痕迹
$http = new Client('https://asite.com', array(
'request.options' => array(
'auth' => array($client_id, $client_secret, 'Basic')
)
$request = $http->post('/oauth/token', null, array(
'code' => $_GET['code'],
'grant_type' => 'authorization_code'
));