thinkphp get/postは微信の共通の方法を要求してテストの万能をしたことがあります

1742 ワード

function https_request($url, $data) { $curl = curl_init(); $timeoutc = 5; curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HTTPHEADER,array("Content-type:multipart/form-data" ));// header  curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $timeoutc); curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22"); curl_setopt($curl, CURLOPT_FOLLOWLOCATION ,1); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($curl, CURLOPT_POST,true); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($curl); curl_close($curl); return $output; }  POST , get , 。 function getAllGrounp() { $access_token = $this->getAccessToken(); $url = "https://api.weixin.qq.com/cgi-bin/groups/get?access_token=".$access_token; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)'); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_AUTOREFERER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $output = curl_exec($ch); curl_close($curl); $data = json_decode($output,true); $this->assign("allgrounp",$data['groups']); $this->display(); }