Development of SMS platform based on CMPP2 and Dongwei API

xiaoxiao2021-03-06  41

Development of the SMS platform based on CMPP2 and Dongwei API Published on www.10ms.net This platform was developed for gateway. East Soft API does not know what version, the source code has an error, and an array allows the length 64, and the API document also shows that 64, but it is 65. Crack, change, recompile, no problem. There are several errors in the sample program in the API document, which is very strange. Since it is a version released, there is no comment, change it, now there is no problem, you can send a text message. The following is just a simple example, to emphasize some details. Suppose you put the API in the D: / Message / Com / CommerceWare / CMPP / Directory, my example is also changing the directory, then compile and run, please transfer to the Message directory compile Javac-ClassPath D: / Message / f: /Message/com/commerce/cmpp/test.java run java com.commerceWare.cmpp.test 13711111111 I love ABC runtime first parameter is the other party mobile phone number, the second parameter is sending content. The following is the program content, login IP and username password, etc. I have hidden.

But the program is normal, you first need to apply for a SP qualification package; public class test {public void readpame (conn_desc con) {cmppe_result cr = null; cmpp cp = new cMPP (); try {cr = cp.readrespack (con); system.out.println ("cr.pack_id =" cr.pack_id); switch (cr.pack_id) {copy 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_Deliv) Er_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: ca ZA: 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 ("Mobile Number Enter is incorrect"); return;} if (args [1] == null || args [0] .Equals (") || args [1] .length () == 0) {system.out.println ("No SMS content"); 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 hide 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 [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] = 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 is 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_resul T = new cmppe_deliver_result (); try {conn_desc con = New conn_desc (); system.out.println ("connect ..."); p.cmpp_connect_to_ismg ("111.1111.111", 7890, con); // Login Information hidden, sorry ha stem.out.println ("ICP_ID:" "******" "ICP_AUTH: " ** "); p.cmpp_login (congestion" ***** ", "****", (byte) 2,0x12, *******); t.set_ICPID (ICP_ID); sub.set_svctype; sub.set_feetype (Fee_Type) Sub.set_infofee; sub.set_protoid; sub.set_msgmode; sub.set_priority (priority); sub.set_validate (validate);

转载请注明原文地址:https://www.9cbs.com/read-74051.html

New Post(0)