HttpClient --- 百度地图LBS云

一、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"
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值