智能机器人接口丰富你自己的公众号

提供免费的笑话接口,丰富你的公众平台,其中requestStr可以换成其他的字符,smart服务会智能返回。
实例参考:

 

参考代码如下:

public static void main(String[] args) {
// TODO Auto-generated method stub
StringBuffer sTotalString= new StringBuffer();
try {

String requestStr = "笑话";

URL url = new URL("http://ironjava.sinaapp.com/smartServlet?content="+URLEncoder.encode(requestStr,"utf-8"));

URLConnection connection = url.openConnection();
String sCurrentLine= "";
InputStream inputStream = connection.getInputStream();

BufferedReader l_reader = new BufferedReader(new InputStreamReader(inputStream,"UTF-8"));
while ((sCurrentLine = l_reader.readLine()) != null) {
sTotalString.append(sCurrentLine + "/r/n");
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(sTotalString.toString());

}

 

 



 
 
 

猜你喜欢

转载自tianziking.iteye.com/blog/2047327