
- UID
- 144909
- 帖子
- 2098
- 精华
- 0
- 威望
- 0
- 阅读权限
- 100
- 来自
- lidia``曾经的上海3-3
- 注册时间
- 2004-5-1
|
package com.sms;
import com.wondertek.esmp.esms.empp.EMPPConnectResp;
import com.wondertek.esmp.esms.empp.EmppApi;
public class SendSMS {
EmppApi emppApi = new EmppApi();
RecvListener listener = new RecvListener(emppApi);
String host = "211.136.163.68";
int port = 9981;
String accountId = "989114";
String password = "598988";
String serviceId = "989114";
public void sendSMS(int orderFormCode, String begin_Date, String init_End_Date,
int init_RoomSum, String roomtype,String MPhone_Num){
try {
//建立同服务器的连接
EMPPConnectResp response = emppApi.connect(host, port, accountId,
password, listener);
System.out.println(response);
if (response == null) {
System.out.println("连接超时失败");
return;
}
if (!emppApi.isConnected()) {
System.out.println("连接失败:响应包状态位=" + response.getStatus());
return;
}
} catch (Exception e) {
System.out.println("发生异常,导致连接失败");
e.printStackTrace();
return;
}
// 发送短信
if (emppApi.isSubmitable()) {
//简单方式发送短信,支持长短信
try{
emppApi.submitMsgAsync("07年好男儿冠军hallobobo");
//同步发送方式update 20060307
//EMPPSubmitSMResp [] resp = emppApi.submitMsg(content,mobiles,serviceId);
//System.out.println("resp result:"+resp[0].getResult());
////////terminate connection.
emppApi.terminateAsync() ;
}catch (Exception e1) {
e1.printStackTrace();
}
}
}
}
[ 本帖最后由 我爱尤那 于 2007-4-7 01:33 编辑 ] |
|