PHP微信公众号开发——公共方法
一.调用第三方接口
/* * $url 接口url string * $type 请求类型 string * $res 返回数据 string * $date 数据 string */
function https_request($url,$type="get",$res="json",$data = ''){ //1.初始化curl $curl = curl_init(); //2.设置curl的参数 curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,2); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); if ($type == "post"){ curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); } //3.采集 $output = curl_exec($curl); //4.关闭 curl_close($curl); if ($res == 'json') { return json_decode($output,true); } }
相关推荐
83911535 2020-11-13
曾是土木人 2020-10-31
yegen00 2020-10-21
soralaro 2020-10-11
katanaFlower 2020-09-18
wytzsjzly 2020-08-17
88407710 2020-08-17
ChinaJoeEE 2020-08-16
CyborgLin 2020-08-15
Blueberry 2020-08-15
PinkBean 2020-08-11
katanaFlower 2020-08-03
hunningtu 2020-07-30
阿债的方寸天地 2020-06-28
pingyan 2020-06-25
wytzsjzly 2020-06-25
阳光岛主 2020-06-25
阿债的方寸天地 2020-06-16