public function getsessionkey() { $appid = config::get('miniappconf')['appid']; $secret = config::get('miniappconf')['appsecret']; $code = $this->request->param('code'); if (!$code) { return json(array('status'=>0,'err'=>'非法操作!')); } $get_token_url = 'https://api.weixin.qq.com/sns/jscode2session?appid='.$appid.'&secret='.$secret.'&js_code='.$code.'&grant_type=authorization_code'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $get_token_url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $res = curl_exec($ch); curl_close($ch); return json(array('status'=>1,'err'=>json_decode($res))); }
本文为看恩吧原创文章,转载无需和我联系,但请注明来自knsay.com