<?phpnamespace Home\Controller;use Think\Controller;class PublicController extends Controller { public function _initialize(){ //判断access_token是否为空 $Appid='wxeba6909c7ff45e04'; $appsecret='498bc191f18975572f0d45b8bc0b4746'; if(!session('?access_token')||session('appsecret')<time()){ $url="https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$Appid."&secret=".$appsecret; //echo $url; $zhi=$this->http_curl($url); echo $zhi; } } public function index() { echo "awdawwg"; } public function http_curl($url, $type='get',$res='json',$arr='') { //curl方法 //echo $url; //开启 $ch=curl_init(); //设置参数 curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); if($type=='post') { //echo '54545454'; curl_setopt($ch,CURLOPT_POST,1); curl_setopt($ch,CURLOPT_POSTFIELDS,$arr); } //采集 $outopt=curl_exec($ch); curl_close($ch); var_dump($outopt); if($res=='json') { return json_decode($outopt,true); } }}喊回来的是false
- 2 回答
- 0 关注
- 1902 浏览
添加回答
举报
0/150
提交
取消