public function demo() { $url='http://demo.com/'; $content = '{ // Json的格式 "serviceName": "changebusList", "queryParameters": { "page": "1", "userid": "66", "querytype": "0" } }';
echo $htt = $this->https_post($url,$content); }
//通过CURL,发送http的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; }
|
请发表评论