我一直在尝试:
$header = array(
"Authorization :Basic $authorization",
"Content-Type: application/json"
);
//option 1
$param='{
"grant_type" : "client_credentials"
}';
//option 2
$param = array("Grant_type: client_credentials",);
//option 3
$param = "grant_type=client_credentials";
//option 4
$a = array(
'grant_type' => 'client_credentials');
$param = http_build_query($a);
$ch = curl_init( $url );
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$param);
curl_setopt($ch,CURLOPT_VERBOSE, true);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,120);
curl_setopt($ch,CURLOPT_TIMEOUT,120);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
$content = curl_exec( $ch );
$err = curl_error($ch);
curl_close( $ch );
我已经尝试了上面的所有选项,但不断收到这样的错误:
response_type or grant_type is required
如何在 curl 概念中传递 grant_type?还是我用错了?
浮云间