微信聊天机器人开发 java源代码 免费接口 图灵机器人

时间:2015-05-26 12:47:49   收藏:0   阅读:600

微信聊天机器人开发  java  


图灵机器人提供免费接口,并且支持java语言开发,同时提供开发说明:

图灵机器人开发说明连接:

http://www.tuling123.com/openapi/cloud/access_api.jsp


实例:

/** 调用图灵机器人平台接口 
*/ 
public static void main(String[] args) throws IOException { 

     String APIKEY = "开发者注册帐号,激活之后即可获得"; 
     String INFO = URLEncoder.encode("北京今日天气", "utf-8"); 
    String getURL = "http://www.tuling123.com/openapi/api?key=" + APIKEY + "&info=" + INFO; 
    URL getUrl = new URL(getURL); 
    HttpURLConnection connection = (HttpURLConnection) getUrl.openConnection(); 
    connection.connect(); 

    // 取得输入流,并使用Reader读取 
    BufferedReader reader = new BufferedReader(new InputStreamReader( connection.getInputStream(), "utf-8"));
    StringBuffer sb = new StringBuffer(); 
    String line = ""; 
    while ((line = reader.readLine()) != null) { 
        sb.append(line); 
    } 
    reader.close(); 
    // 断开连接 
    connection.disconnect(); 
    System.out.println(sb); 

}


评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!