public static function createOrUpdate($id, $title, $address, $latitude, $longitude, $type = 'create') { $querystring_arrays = array(); $uri = ''; if ($type == 'create') { //这里是创建 $uri = '/geodata/v3/poi/create'; $querystring_arrays = array('id' => $id, 'title' => $title, 'latitude' => $latitude, 'longitude' => $longitude, 'coord_type' => 1, 'geotable_id' => GEOTABLE_ID, 'ak' => MAP_AK); } else { //这里是更新 $uri = '/geodata/v3/poi/update'; $querystring_arrays = array('id' => $id, 'title' => $title, 'latitude' => $latitude, 'longitude' => $longitude, 'coord_type' => 1, 'geotable_id' => GEOTABLE_ID, 'ak' => MAP_AK); } $sn = BDLbs::caculateAKSN($uri, $querystring_arrays, "POST"); $querystring_arrays['sn'] = $sn; Yii::trace(CVarDumper::dumpAsString($querystring_arrays), 'create or update baidu poi post'); $ret = Yii::app()->curl->post(Yii::app()->params['baiduapi'] . $uri, $querystring_arrays); $ret = json_decode($ret, true); Yii::trace(CVarDumper::dumpAsString($ret), 'create or update baidu poi'); if ($ret['status'] == 0) { return $ret['id']; } else { Yii::log(CVarDumper::dumpAsString($ret), 'error', 'create or update baidu poi ERROR'); return -1; } }
public static function createOrUpdate($udid) { $type = 'update'; $userid = UserIdentity::getuserid($udid); $community = Community::model()->findByAttributes(array('user_id' => $userid)); if (!$community) { $community = new Community(); $type = 'create'; } $userlocate = User::model()->get_locate()->findByPk($userid); $community->user_id = $userid; $community->begin_time = self::getTime(); $community->lng = $userlocate->y; $community->lat = $userlocate->x; $community->type = 1; $community->communityid = uniqid("", true); $community->des = $userlocate->nickname . "的漂流伞"; if (!$community->save()) { Yii::log(CVarDumper::dumpAsString($community->errors), 'error', 'Community new save error'); } else { BDLbs::createOrUpdate(intval($community->id), $community->des, $community->des, $community->lat, $community->lng, $type); return true; } }
public function actionBoundsearch() { echo BDLbs::Bound(); }