一、HttpClient --- 百度地图LBS云存储
public class BaiduMapCloudStorageTest {
// 创建表
@Test
public void demo1() throws IOException {
HttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost("http://api.map.baidu.com/geodata/v3/geotable/create");
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("name", "mytable1"));
nameValuePairs.add(new BasicNameValuePair("geotype", "1"));
nameValuePairs.add(new BasicNameValuePair("is_published", "1"));
nameValuePairs.add(new BasicNameValuePair("ak", "xxxxxx"));
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
System.out.println(EntityUtils.toString(httpEntity));
}
@Test
// 查询表
public void demo2() throws IOException {
HttpClient httpClient = HttpClients.createDefault();
HttpGet httpGet = new HttpGet(
"http://api.map.baidu.com/geodata/v3/geotable/list?ak=xxxxxx");
HttpResponse httpResponse = httpClient.execute(httpGet);
HttpEntity httpEntity = httpResponse.getEntity();
System.out.println(EntityUtils.toString(httpEntity));
}
@Test
// 查询表结构
public void demo3() throws IOException {
HttpClient httpClient = HttpClients.createDefault();
HttpGet httpGet = new HttpGet(
"http://api.map.baidu.com/geodata/v3/geotable/detail?id=153944&ak=xxxxxx");
HttpResponse httpResponse = httpClient.execute(httpGet);
HttpEntity httpEntity = httpResponse.getEntity();
System.out.println(EntityUtils.toString(httpEntity));
}
@Test
// 创建列
public void demo4() throws IOException {
HttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost("http://api.map.baidu.com/geodata/v3/column/create");
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("geotable_id", "153944"));
nameValuePairs.add(new BasicNameValuePair("name", "名称"));
nameValuePairs.add(new BasicNameValuePair("key", "name"));
nameValuePairs.add(new BasicNameValuePair("type", "3"));
nameValuePairs.add(new BasicNameValuePair("max_length", "512"));
nameValuePairs.add(new BasicNameValuePair("is_sortfilter_field", "0"));
nameValuePairs.add(new BasicNameValuePair("is_search_field", "1"));
nameValuePairs.add(new BasicNameValuePair("is_index_field", "1"