2 回答
TA贡献2037条经验 获得超6个赞
H 选项意味着您应该在标题中传递参数。
尝试这个:
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Bearer YOUR_ACCESS_TOKEN'
));
TA贡献1895条经验 获得超3个赞
试试这个代码:
function httpPostRequest($url, $strRequest,$auth)
{
$fields = array(
'strRequest' => $strRequest,
'access_token' => $access_token
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
$isSecure = strpos($url, "https://");
if ($isSecure === 0) {
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
}
$result = curl_exec($ch);
$this->errorCode = curl_errno($ch);
$this->errorMessage = curl_error($ch);
return $result;
}
- 2 回答
- 0 关注
- 156 浏览
添加回答
举报