调用第三方api之图灵机器人
来源:互联网 发布:单片机简易密码锁 编辑:程序博客网 时间:2024/05/16 03:54
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Scanner;
/**
* 第三方接口
*
* @author Administrator
*
*/
public class ThirdInterface {
public static void question(String info) throws IOException {
URL url = new URL(
"http://www.tuling123.com/openapi/api?key=026efbd4eda9a99726a1d939fab35acc&info="
+ URLEncoder.encode(info, "UTF-8"));
HttpURLConnection httpURLConnection = (HttpURLConnection) url
.openConnection();
// 5000如果没有连接,抛出异常
httpURLConnection.setConnectTimeout(5000);
// 连续并响应成功
if (httpURLConnection.getResponseCode() == 200) {
try (InputStream inputStream = httpURLConnection.getInputStream();
Scanner scanner = new Scanner(inputStream);) {
scanner.hasNext();
String result = scanner.nextLine();
System.out.println("answer:"
+ result.substring(result.indexOf("\":\"") + 3,
result.indexOf("\"}")));
}
}
}
public static void main(String[] args) throws IOException {
question("");
}
}
0 0
- 调用第三方api之图灵机器人
- 图灵机器人api调用
- python 调用图灵机器人api实现简单的人机交互
- 使用httpclient实现图灵机器人web api调用实例
- itchat微信调用图灵机器人API
- PHP图灵机器人问答机器人API调用代码实例
- 第三方平台API调用
- 图灵机器人聊天api
- 图灵机器人API接入
- Java 调用图灵机器人
- 第三方API的调用开发
- 微信调用第三方API
- 第三方快递接口API调用
- Android之图灵机器人
- 介绍图灵机器人php API
- 机器人api(图灵机器人)
- 图灵机器人聊天接口api
- 百度API集市与图灵机器人
- printf,scanf、malloc、realloc、calloc(与c++的new的区别)的各种用法
- 对 Android 开发者有益的 40 条优化建议
- 病毒营销的三个经典案例(转)
- 【 MVC 】显示数据库数据表格
- 操作符重载及友元函数
- 调用第三方api之图灵机器人
- C++ ->重载
- 游戏类型
- leetcode260-single number iii
- Logistic回归总结
- Scrum 之 检查单
- 为什么python
- 二分法
- ajax解析xml和json文件的具体实现