Exemplo n.º 1
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']));
 }
Exemplo n.º 2
0
 public function QRcode()
 {
     \Predis\Autoloader::register();
     $redis = new \Predis\Client();
     //生成二维码
     $numberid = M('randnumber')->add(array('openid' => ''));
     $token = base64_encode(authcode($numberid, "ENCODE", SESSION_AUTH));
     //设置标志有效时间
     $redis->setex('__WX_NUMBERID_' . $numberid, 300, 'true');
     $rs = json_decode(Http::CurlRequst("http://api.wwei.cn/wwei", array("data" => $token, 'apikey' => 20150828111302), "GET"), true);
     $this->assign('erweima', $rs['data']['qr_filepath']);
     $this->assign('token', $token);
     $this->display();
 }