コード例 #1
0
 public function confirm()
 {
     if (IS_POST) {
         if ($this->redis->get($this->wx_numberid_name . intval(I('post.numberid'))) && I('post.confirm') == 'true') {
             $this->redis->setex($this->wx_auth_name . intval(I('post.numberid')), 150, ACPopedom::getID());
             //提示登陆成功
             header("HTTP/1.1 200");
             exit;
         } else {
             header("HTTP/1.1 400");
             exit;
         }
     }
     $nmberid = authcode(base64_decode(trim(I('get.token'))), "DECODE", SESSION_AUTH);
     if (!intval($nmberid)) {
         //解析不成功
         $this->ajaxReturn(array('status' => false, 'msg' => '无效的二维码'));
     }
     if (!$this->redis->get($this->wx_numberid_name . $nmberid)) {
         //解析不成功
         $this->ajaxReturn(array('status' => false, 'msg' => '此二维码已过期,请刷新页面再扫!'));
     }
     //生成扫码通过标识,并绑定扫码带来的numberid
     $this->redis->setex($this->wx_login_name . $nmberid, 150, ACPopedom::getAvator());
     $this->ajaxReturn(array('status' => true, 'numberid' => $nmberid));
 }
コード例 #2
0
 public function upload()
 {
     $i = I('post.i');
     $id = ACPopedom::getID() ? ACPopedom::getID() : 43543;
     $subName = substr(md5($id), -1);
     $result = UploadFile($subName, "/Attachment/", '/upload/');
     $result['i'] = $i;
     $this->ajaxReturn($result);
 }
コード例 #3
0
 /**
  * 更新地理位置
  */
 public function getLocation()
 {
     $longitude = I('get.longitude');
     $latitude = I('get.latitude');
     $baiduLongLat = json_decode(Http::CurlRequst('http://api.map.baidu.com/geoconv/v1/', array('coords' => $longitude . ',' . $latitude, 'from' => 3, 'to' => 5, 'ak' => 'mcFKx7aa0WB73SAW6b2IYQAP'), 'get'), true);
     if ($baiduLongLat['status'] !== 0) {
         $this->ajaxReturn(array('status' => false, 'msg' => '获取地址失败1'));
     }
     $location = json_decode(Http::CurlRequst('http://api.map.baidu.com/geocoder/v2/', array('location' => $baiduLongLat['result'][0]['x'] . ',' . $baiduLongLat['result'][0]['y'], 'output' => 'json', 'pois' => 0, 'ak' => 'mcFKx7aa0WB73SAW6b2IYQAP'), 'get'), true);
     if ($location['status'] !== 0) {
         $this->ajaxReturn(array('status' => false, 'msg' => '获取地址失败2'));
     }
     //存放坐标
     $res = M('Users')->where('userid = ' . ACPopedom::getID())->save(array('longitude' => $baiduLongLat['result'][0]['x'], 'latitude' => $baiduLongLat['result'][0]['y']));
     if (!$res) {
         $this->ajaxReturn(array('status' => false, 'msg' => '保存地址失败'));
     }
     $this->ajaxReturn(array('status' => true, 'msg' => '地理位置已更新', 'address' => $location['result']['formatted_address'], 'lng' => $baiduLongLat['result'][0]['x'], 'lat' => $baiduLongLat['result'][0]['y']));
 }
コード例 #4
0
 public function _initialize()
 {
     import("Vendor.WeiXin.Wechat");
     $this->_wechat = new Wechat(array('token' => C('TOKEN'), "appid" => C('AUTH_APPID'), "appsecret" => C('AUTH_APPSECRET'), 'debug' => true));
     // 验证微信推送的签名
     //$this->_wechat->valid();
     //$this->_wechat->checkAuth();
     $this->_wechat->getRev();
     switch ($this->_wechat->getRevType()) {
         //文字类型
         case Wechat::MSGTYPE_TEXT:
             $this->_wechat->text('客官,请切换到菜单模式,更多精彩等着你。')->reply();
             //$this->replyText($this->_wechat->getRevContent());
             break;
             //事件推送类型
         //事件推送类型
         case Wechat::MSGTYPE_EVENT:
             $this->replyEvent($this->_wechat->getRevEvent());
             break;
         case Wechat::MSGTYPE_VOICE:
             $this->_wechat->text('客官,语音暂时还未开通,请切换到菜单模式体验更多精彩')->reply();
             break;
         case Wechat::MSGTYPE_IMAGE:
             $this->_wechat->text('客官,图片暂时还未开通,请切换到菜单模式体验更多精彩')->reply();
             break;
         case Wechat::MSGTYPE_LOCATION:
             //上报地理位置
             //$data = $this->_wechat->getRevEventGeo();
             //$this->_wechat->text('客官,你的地理位置所在经度为:'.$data['x'].',纬度为:'.$data['y'])->reply();
             break;
     }
     /* cookie('__WX_UID__',null);
        cookie('__WX_AVATOR__',null);
        cookie('__WX_NICKNAME__',null);
        cookie('__WX_AUTH_TOKEN__',null);
        exit;*/
     if (!ACPopedom::isLogin()) {
         $oauthurl = $this->_wechat->getOauthRedirect(SITE_URL . '/index.php/WeChat/Auth/auth', C("AUTH_STATUS"), 'snsapi_userinfo');
         cookie("__refer__", authcode(SITE_URL . $_SERVER['REQUEST_URI'], "ENCODE", SESSION_AUTH, C('EXPIRE_TIME')));
         header("Location:" . $oauthurl);
     }
 }
コード例 #5
0
 public function test()
 {
     $sign = ACPopedom::getWechatSign();
     $this->assign('wxSdk', $sign);
     $this->display('aside');
 }