标签:
该代码是实现附近的生活服务类查询,如:附近的酒店、银行、加油站等等,
借助图灵机器人提供的免费端口就能简单快速实现,返回的结果为json格式
附近的酒店请求示例
请求示例: http://www.tuling123.com/openapi/api?key=KEY&info=北京中关村附近的酒店 { "code":309000, "text":"********", "list":[{ "name":"", "price":"", "satisfaction":"", "count":"", "detailurl":"" "icon":"" }] }
JAVA接入方式
/** 调用图灵机器人平台接口 http://www.tuling123.com/openapi/cloud/access_api.jsp * 需要导入的包:commons-logging-1.0.4.jar、 httpclient-4.3.1.jar、httpcore-4.3.jar */ public static void main(String[] args) throws IOException { String APIKEY = "开发者注册帐号,激活之后即可获得"; String INFO = URLEncoder.encode("北京今日天气", "utf-8"); String requesturl = "http://www.tuling123.com/openapi/api?key="+APIKEY+"&info="+INFO; HttpGet request = new HttpGet(requesturl); HttpResponse response = HttpClients.createDefault().execute(request); //200即正确的返回码 if(response.getStatusLine().getStatusCode()==200){ String result = EntityUtils.toString(response.getEntity()); System.out.println("返回结果:"+result); } }
标签:
原文地址:http://www.cnblogs.com/uoou123/p/4272120.html