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; } }