💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
需要通过微信服务器推送的消息数据 获取二维码扫描结果 ``` public function get_ticket() { $token = $this->gettoken(); $url = 'https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token='.$token;//.$token $post=['expire_seconds'=>172800,'action_name'=>'QR_STR_SCENE','action_info'=>['scene'=>['scene_str'=>'test']]]; $obj = $this->curl($url,json_encode($post)); $data = json_decode($obj, true); $ticket = $data['ticket']; return $ticket; } public function wx_qrcode(){ $result['ticket']=$this->get_ticket(); $result['url']='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket='.UrlEncode($result['ticket']); return show(0,'ok',$result); } /** * 二维码扫描结果 */ public function ticket_result() { $ticket = input('get.ticket'); $openid=Cache::get($ticket); if(empty($openid)==true){ return show(-2,'二维码已过期'); } $user=Db::table('user')->where('openid',$openid)->find(); if($user){ $data=$this->user_info($user); return show(0,'ok',$data); }else{ return show(-1,'未绑定微信',$openid); } } //通过微信服务器推送的消息数据 获取二维码扫描结果 protected function response_msg() { $postStr = file_get_contents('php://input'); libxml_disable_entity_loader(true); $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA); // $MsgType =trim($postObj->MsgType); $FromUserName =trim($postObj->FromUserName); $Ticket=trim($postObj->Ticket); // $ToUserName =trim($postObj->ToUserName); // $Event =trim($postObj->Event); //'event' and $Event=='subscribe' if(isset($Ticket)){ Cache::set($Ticket,$FromUserName,172000); } } ```