标题和正文的卷曲参数CURLOPT_POSTFIELDS

问题描述 投票:0回答:1

我想从此服务接收授权码

API

我的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);
?>

我不知道我的参数是否正确,结果是result

curl post
1个回答
0
投票

在我的配置中,POST中的字段需要http_build_query函数:

CURLOPT_POSTFIELDS => http_build_query($avoir_jeton));
© www.soinside.com 2019 - 2024. All rights reserved.