我想从此服务接收授权码
我的PHP代码如下:
<?php
$code_hubrise = '865a581274da...';
$client_id = '9822xxxx.clients.hubrise.com';
$client_secret = '06a250e750...688bc01fec3d8619';
$lien_jeton = 'https://manager.hubrise.com/oauth2/v1/token';
$header_jeton = array('Content-Type: application/x-www-form-urlencoded');
$avoir_jeton = array(
'code' => $code_hubrise,
'client_id' => $client_id,
'client_secret' => $client_secret);
$options_jeton = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => true,
CURLOPT_POST => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_HTTPHEADER => $header_jeton,
CURLOPT_URL => $lien_jeton,
CURLOPT_POSTFIELDS => $avoir_jeton);
$curl = curl_init();
curl_setopt_array($curl,$options_jeton);
$retour = curl_exec($curl);
print $retour;
curl_close($curl);
?>
在我的配置中,POST中的字段需要http_build_query函数:
CURLOPT_POSTFIELDS => http_build_query($avoir_jeton));