private function _httpGet($url=""){ $curl = curl_init(); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_TIMEOUT, 500); // 为保证第三方服务器与微信服务器之间数据传输的安全性,所有微信接口采用https方式调用,必须使用下面2行代码打开ssl安全校验。 // 如果在部署过程中代码在此处验证失败,请到 http://curl.haxx.se/ca/cacert.pem 下载新的证书判别文件。 curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_URL, $url); $res = curl_exec($curl); curl_close($curl); return $res; } private function _httpPost($url="" ,$requestData=array()){ $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); //发送json数据 //$requestData = '{"name":"hello","age":122,"arr":{"arrid":44,"name":"world","test":[333,444,555,66,"xxdfads"]}}'; //curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length:' . strlen($requestData))); //curl_setopt($curl, CURLOPT_POSTFIELDS, $requestData); //服务器端接收json数据 file_get_contents('php://input'); //普通数据 curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($requestData)); $res = curl_exec($curl); curl_close($curl); return $res; }