Tag: wit.ai

wit.ai – 如何用Java发送请求?

我正在使用Java中的wit.ai开发一个虚拟助手,但是我仍然无法发出HTTP请求。 我不是Java中的HTTP请求的专家,我一直得到400错误。 这是我的代码: public class CommandHandler { public static String getCommand(String command) throws Exception { String url = “https://api.wit.ai/message”; String key = “TOKEN HERE”; String param1 = “20141022”; String param2 = command; String charset = “UTF-8”; String query = String.format(“v=%s&q=%s”, URLEncoder.encode(param1, charset), URLEncoder.encode(param2, charset)); URLConnection connection = new URL(url + “?” + query).openConnection(); connection.setRequestProperty (“Authorization […]