一个简单的对话机器人

使用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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值