现有一个url,只要传一个message和telephone 就行了。
代码如下:
private static int BASE_BODY_SIZE = 10240;
private static int INC_BODY_SIZE = 51200;
public void sendSMS(String mobilePhone, String message){
String endPoint = "http://econnect.hotdotchina.com/econnect/pitf/submit.jsp?uid=wuyou&pswd=wy0051&extno=0051";
String url = endPoint + "&mob=" + mobilePhone + "&msg=" + message;
this.send(url);
}
public void send(String url){
HttpClient httpClient = new HttpClient();
PostMethod method = new PostMethod(url);
try {
int retcode = httpClient.executeMethod(method);
if (retcode == HttpStatus.SC_OK) {
byte[] responseBody = new byte[BASE_BODY_SIZE];
java.io.InputStream istream = method.getResponseBodyAsStream();
int npos = 0;
int nread = 0;
while ((nread = istream.read(responseBody, npos,
responseBody.length - npos)) >= 0) {
npos += nread;
if (npos >= responseBody.length) {
byte[] tmpBuf = new byte[npos + INC_BODY_SIZE];
System.arraycopy(responseBody, 0, tmpBuf, 0, npos);
responseBody = tmpBuf;
}
}
}
} catch (Exception e) {
log.error("", e, "");
}
可这时接受到的短信中文不能显示,有谁知道为什么?