package com.lwz.wx.util;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.Scanner;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.methods.GetMethod;
public class chat {
public static void main(String[] args) {
while(true){
Scanner hp=new Scanner(System.in);
String chat=hp.next();
String recontent=chatting(chat);
System.err.println("对方说"+recontent);
hp.reset();
}
}
public static String chatting(String content){
String eString=URLEncoder.encode(content);
String u="http://xiaofengrobot.sinaapp.com/api.php?text="+eString;
HttpClient client=new HttpClient();
GetMethod get=new GetMethod(u);
String str="";
try {
client.executeMethod(get);
str=new String(get.getResponseBodyAsString().getBytes("iso-8859-1"),"utf-8");
} catch (HttpException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
import java.io.IOException;
import java.net.URLEncoder;
import java.util.Scanner;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.methods.GetMethod;
public class chat {
public static void main(String[] args) {
while(true){
Scanner hp=new Scanner(System.in);
String chat=hp.next();
String recontent=chatting(chat);
System.err.println("对方说"+recontent);
hp.reset();
}
}
public static String chatting(String content){
String eString=URLEncoder.encode(content);
String u="http://xiaofengrobot.sinaapp.com/api.php?text="+eString;
HttpClient client=new HttpClient();
GetMethod get=new GetMethod(u);
String str="";
try {
client.executeMethod(get);
str=new String(get.getResponseBodyAsString().getBytes("iso-8859-1"),"utf-8");
} catch (HttpException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
(淘宝出售微盟,小猪,微俱聚源码 淘宝链接:http://linwenzhou.taobao.com)