grant_type引发的问题
functioncurlPost($url, $headers, $post){
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
if(!
empty($headers)){
curl_setopt($ch,CURLOPT_HTTPHEADER,$headers);
}
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
//POST数据
curl_setopt($ch, CURLOPT_POST,
1);
//设置为POST方式
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
//POST数据
curl_setopt($ch, CURLOPT_RETURNTRANSFER,
1);
//如果成功只将结果返回,不自动输出任何内容。
curl_setopt($ch, CURLOPT_HEADER,
0);
//如果想把一个头包含在输出中,设置这个选项为一个非零值。
curl_setopt($ch, CURLINFO_HEADER_OUT,
1);
//启用时追踪句柄的请求字符串。
$json = curl_exec($ch);
$headers = curl_getinfo($ch, CURLINFO_HEADER_OUT);
echo
"
=====请求返回=====
";
echo
"out headers: ".$headers .
"
";
$hearLen = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
echo
"header len: ".$hearLen .
"
";
$statuscode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
echo
"httpcode: ".$statuscode.
"
";
echo
"
===================
";
return $json;
@curl_close($ch);
}
会报grant_type找不到
改成如下
functioncurlPost($url, $headers, $post){
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
if(!empty($headers)){
curl_setopt($ch,CURLOPT_HTTPHEADER,$headers);
}
curl_setopt($ch, CURLOPT_POST, 1);//设置为POST方式
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));//POST数据
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); //如果成功只将结果返回,不自动输出任何内容。
curl_setopt($ch, CURLOPT_HEADER,0);//如果想把一个头包含在输出中,设置这个选项为一个非零值。
curl_setopt($ch, CURLINFO_HEADER_OUT,1);//启用时追踪句柄的请求字符串。
$json = curl_exec($ch);
$headers = curl_getinfo($ch, CURLINFO_HEADER_OUT);
echo"
=====请求返回=====
";
echo"out headers: ".$headers ."
";
$hearLen = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
echo"header len: ".$hearLen ."
";
$statuscode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
echo"httpcode: ".$statuscode."
";
echo"
===================
";
return $json;
@curl_close($ch);
}
即成功返回值
以上是 grant_type引发的问题 的全部内容, 来源链接: utcz.com/z/514804.html