标签:
public function demo() {
$url=‘http://demo.com/‘;
$content = ‘{
"serviceName": "changebusList",
"queryParameters": {
"page": "1",
"userid": "66",
"querytype": "0"
}
}‘;
echo $htt = $this->https_post($url,$content);
}
//模拟post请求
public function https_post($url,$data){
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
if(curl_errno($curl)) {
return ‘Errno‘.curl_errno($curl);
}
curl_close($curl);
return $result;
}
标签:
原文地址:http://www.cnblogs.com/wangyuman26/p/5545370.html