国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

基于CMPP2及東軟API短信平臺的開

2019-11-18 19:26:35
字體:
來源:轉載
供稿:網友

  本平臺針對網關開發。

  東軟API不知道是什么版本的,源代碼出現某個錯誤,某數組允許長度64,API文檔里也說明是64,可是它是65。破解之,改之,重新編譯之,無問題。

  API文檔里示例程序也有若干錯誤,很奇怪,既然是對外發布的版本,居然沒有一條注釋,改之,現在調試運行沒有問題,可以發送短信。

  下面提供的只是個簡單的示例,要強調一些細節。假設你把API放在d:/message/com/commerceware/cmpp/ 目錄下,我的示例也在改目錄下,那么編譯和運行請轉到message目錄下

  編譯javac -classpath D:/message/ f:/message/com/commerceware/cmpp/Test.java
  運行java com.commerceware.cmpp.Test 13711111111 我愛ABC

  運行時第一個參數是對方手機號,第二個參數是發送內容。以下是程序內容,登陸ip和用戶名密碼等我已隱藏。但程序是正常的,你首先需要申請一個SP的資格:

package com.commerceware.cmpp;

public class Test{

public void readPaME(conn_desc con)
{
cmppe_result cr = null;
CMPP cp = new CMPP();
try{
cr = cp.readResPack(con);
System.out.switch(cr.pack_id)
{
case CMPP.CMPPE_NACK_RESP:


System.out.println("CMPP.CMPPE_NACK_RESP:get nack pack");
break;

case CMPP.CMPPE_LOGIN_RESP:
cmppe_login_result cl;
cl = (cmppe_login_result)cr;


System.out.println("CMPP.CMPPE_LOGIN_RESP:login resp: STAT = "+cl.stat);
break;

case CMPP.CMPPE_LOGOUT_RESP:


System.out.println("CMPP.CMPPE_LOGOUT_RESP:logout resp: STAT = "+cr.stat);
break;

case CMPP.CMPPE_SUBMIT_RESP:


System.out.println("CMPP.CMPPE_SUBMIT_RESP");
cmppe_submit_result sr;
sr = (cmppe_submit_result)cr;
cmppe_cancel cc1 = new

cmppe_cancel();
//cc1.set_msgid(new

String(sr.msg_id)));
cc1.set_msgid(new

String(sr.msg_id));
break;

case CMPP.CMPPE_DELIVER:


System.out.println("CMPP.CMPPE_DELIVER:deliver: STAT = 0");


cmppe_deliver_result cd=

(cmppe_deliver_result)cr;


cp.cmpp_send_deliver_resp(con,cd.seq,cd.stat);
break;

case CMPP.CMPPE_CANCEL_RESP:


System.out.println("CMPP.CMPPE_CANCEL_RESP:cancel: STAT = " + cr.stat);
break;
case CMPP.CMPPE_ACTIVE_RESP:


System.out.println("CMPP.CMPPE_ACTIVE_RESP:active resp: STAT " + cr.stat);
break;
default:
break;


}
}catch(Exception e)
{
System.out.println(e.getMessage());
e.printStackTrace();
System.out.println("have a exception");
try{
System.in.read();
}catch(Exception e1){}

}
}

public static void main(String[] args)
{

if(args[0] == null || args[0].equals("") || args[0].length() != 11){
System.out.println("手機號碼輸入不正確");
return;
}
if(args[1] == null || args[0].equals("") || args[1].length() == 0){
System.out.println("沒有輸入短信內容");
return;
}

CMPP p = new CMPP();
Test t = new Test();
char test[] = new char[10];
byte short_msg[] = new byte[150];
byte buf[] = new byte[40];
byte b1[] = new byte[10];


cmppe_submit sub = new cmppe_submit();
cmppe_submit_result res =new cmppe_submit_result();
cmppe_cancel can = new cmppe_cancel();

byte icp_id[] = new byte[10]; //ICP隱藏
icp_id[0] =0x**;
icp_id[1] =0x**;
icp_id[2] =0x**;
icp_id[3] =0x**;
icp_id[4] =0x**;
icp_id[5] =0x**;
icp_id[6] = 0;
byte svc_type[] = new byte[6];
svc_type[0] = 0x39;
svc_type[1] = 0x34;
svc_type[2] = 0x31;
svc_type[3] = 0x30;
svc_type[4] = 0;

byte fee_type = 0;
byte info_fee = 1;
byte proto_id = 1;

byte msg_mode = 1;
byte priority =9;
byte fee_utype = 2;
byte fee_user[] = new byte[CMPP.CMPPE_MAX_MSISDN_LEN];
for(int i=0; i<12; i++)
fee_user[0] = 0x31;
fee_user[1] = 0x33;
fee_user[2] = 0x38;
fee_user[3] = 0x30;
fee_user[4] = 0x35;
fee_user[5] = 0x30;
fee_user[6] = 0x30;
fee_user[7] = 0x31;
fee_user[8] = 0x30;
fee_user[9] = 0x36;
fee_user[10]= 0x34;
fee_user[11]= 0x0;

byte validate[] = new byte[10];
validate[0] =0;
byte schedule[] = new byte[2];
schedule[0] =0;
byte src_addr[] = new byte[12];
src_addr[0] = 0x31;
src_addr[1] = 0x33;
src_addr[2] = 0x38;
src_addr[3] = 0x30;
src_addr[4] = 0x35;
src_addr[5] = 0x30;
src_addr[6] = 0x30;
src_addr[7] = 0x31;
src_addr[8] = 0x30;
src_addr[9] = 0x36;
src_addr[10]= 0x34;
src_addr[11]= 0x0;

byte du_count = 1;
byte dst_addr[][] = new byte[10][15];

dst_addr[0][0] = toHex(args[0].charAt(0)); //CMPPE_MAX_MSISDN_LEN+1
dst_addr[0][1] = toHex(args[0].charAt(1));
dst_addr[0][2] = toHex(args[0].charAt(2));
dst_addr[0][3] = toHex(args[0].charAt(3));
dst_addr[0][4] = toHex(args[0].charAt(4));
dst_addr[0][5] = toHex(args[0].charAt(5));
dst_addr[0][6] = toHex(args[0].charAt(6));
dst_addr[0][7] = toHex(args[0].charAt(7));
dst_addr[0][8] = toHex(args[0].charAt(8));
dst_addr[0][9] = toHex(args[0].charAt(9));
dst_addr[0][10]= toHex(args[0].charAt(10));
dst_addr[0][11]= 0x0;

 

//byte data_coding = 1;
byte data_coding = 15; //15為GB2312
byte sm_len = 120;

String ss = args[1];

try{
short_msg = ss.getBytes("GB2312");
ss = new String(short_msg);
}catch(Exception e){

}
System.out.println(short_msg.length);

cmppe_result cr = new cmppe_result();
cmppe_deliver_result rs = new cmppe_deliver_result();
try{
conn_desc con = new conn_desc();
System.out.println("connecting...");
p.cmpp_connect_to_ismg("111.111.111.111",7890,con); //登

陸信息隱藏,SORRY哈
System.out.println("ICP_ID:" + "******" + " ICP_AUTH:" + "**");
p.cmpp_login(con,"*****","****",(byte)2,0x12,*******);
t.readPaME(con);

sub.set_icpid(icp_id );
sub.set_svctype(svc_type);
sub.set_feetype(fee_type );
sub.set_infofee(info_fee);
sub.set_protoid(proto_id);
sub.set_msgmode(msg_mode );
sub.set_priority(priority );
sub.set_validate(validate);
sub.set_schedule(schedule );
sub.set_feeutype(fee_utype);
sub.set_feeuser(fee_user);
sub.set_srcaddr(src_addr );
sub.set_dstaddr(dst_addr );
sub.set_ducount(du_count);

sub.set_msg(data_coding,short_msg.length,short_msg );
p.cmpp_submit(con,sub);
t.readPaME(con);
p.cmpp_active_test(con);
t.readPaME(con);

p.cmpp_logout(con);
t.readPaME(con);

}catch(Exception e)
{
System.out.println(e.getMessage());
e.printStackTrace();
System.out.println("have a exception");
try{
System.in.read();
}catch(Exception e1)
{
}
return;
}
}

public static byte toHex(char c){
switch(c){
case ?':
return 0x31;
case ?':
return 0x32;
case ?':
return 0x33;
case ?':
return 0x34;
case ?':
return 0x35;
case ?':
return 0x36;
case ?':
return 0x37;
case ?':
return 0x38;
case ?':
return 0x39;
case ?':
return 0x30;
default: break;
}
return 0x0;
}

  如果您運行該程序得到該結果,就說明正常。

7
connecting...
ICP_ID:111111 ICP_AUTH:1111
login_type:2
CMPP_VERSION:18
cr.pack_id=-2147483647
CMPP.CMPPE_LOGIN_RESP:login resp: STAT = 0
cr.pack_id=5
CMPP.CMPPE_DELIVER:deliver: STAT = 0
cr.pack_id=-2147483644
CMPP.CMPPE_SUBMIT_RESP
cr.pack_id=-2147483640
CMPP.CMPPE_ACTIVE_RESP:active resp: STAT 0 

  主要看stat是0就行了,其它的是我的調試信息,首行7表示短信長度


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 云龙县| 肃南| 汤原县| 诸暨市| 微博| 色达县| 马公市| 邹城市| 万年县| 澄江县| 新晃| 泾阳县| 元谋县| 石家庄市| 加查县| 和政县| 宜宾县| 德钦县| 孝昌县| 故城县| 磐安县| 云龙县| 五家渠市| 叶城县| 贵溪市| 丰顺县| 宾阳县| 杭锦旗| 静安区| 绍兴市| 闽侯县| 皋兰县| 南丹县| 五河县| 汶川县| 阿克陶县| 新野县| 蒙自县| 鲁山县| 武清区| 乌拉特前旗|