/** * 获取Token值 * @param $corpid * @param $corpsecret * @return mixed * @author 宁佳兵 <meilijing.ning@foxmail.com> */ function getToken($corpid,$corpsecret){ $url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=".$corpid."&corpsecret=".$corpsecret.""; $access_token = httpUrl($url); return $access_token; } /** * 远程调用url * @param $url * @param null $data * @return mixed * @author 宁佳兵 <meilijing.ning@foxmail.com> */ function httpUrl($url,$data = null){ $ch = curl_init (); curl_setopt ( $ch, CURLOPT_URL, $url ); curl_setopt ( $ch, CURLOPT_POST, 1 ); curl_setopt ( $ch, CURLOPT_HEADER, 0 ); curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt ( $ch, CURLOPT_POSTFIELDS, $data ); $result = curl_exec ( $ch ); curl_close ( $ch ); $arr=json_decode($result, true); return $arr; }