使用java开发,需要添加三个包
commons-logging-1.0.4.jar、 httpclient-4.3.1.jar、httpcore-4.3.jar
下载页面
http://download.csdn.net/detail/qaqwe/7744129
http://download.csdn.net/detail/qaqwe/7743941
http://download.csdn.net/detail/qaqwe/7749127
public class wether_req {
public void weatherReq() throws ClientProtocolException, IOException{
String INFO = URLEncoder.encode("杭州今日天气", "utf-8");
String requesturl = "http://www.tuling123.com/openapi/api?key=这边需要填写你注册好后得到的密钥&info="+INFO;
//String requesturl = "http://www.yeetrack.com/";
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.tuling123.com/openapi/cloud/api.jsp?section=7