高分送出!!最高只能设置300分,不够可以再加!华为CMPP API的问题(300分)

  • 主题发起人 主题发起人 pping
  • 开始时间 开始时间
P

pping

Unregistered / Unconfirmed
GUEST, unregistred user!
在华为的API中submit时如何填写多个手机号码?<br>function corp_SubmitAExEx(<br> &nbsp;const OrgTON: Byte; //源地址号码类型 1<br> &nbsp;const OrgNPI: Byte; //源地址编码方案 1<br> &nbsp;const OrgAddr: PChar; //源地址 char[MAX_ADDR_LEN] &nbsp; 10692000522XXXX<br> &nbsp;const DestTON: Byte; //目标地址号码类型 &nbsp;2<br> &nbsp;const DestNPI: Byte; //目标地址编码方案 &nbsp;1<br> &nbsp;const DestAddr: PChar; //目标地址 char[MAX_ADDR_LEN] &nbsp;''<br> &nbsp;const PRI: Byte; &nbsp;//SM优先级 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0<br> &nbsp;const RD: Byte; &nbsp;//当源地址和目的地址相同时,是否替换存在的短消息。 &nbsp; 0<br> &nbsp;const RP: Byte; &nbsp;//回应路径 &nbsp; &nbsp; 0<br> &nbsp;const SRR: Byte; &nbsp;//是否需要状态报告 &nbsp; &nbsp;1<br> &nbsp;const MR: Byte; &nbsp;//消息索引 &nbsp; &nbsp; &nbsp;0<br> &nbsp;const DCS: Byte; &nbsp;//数据编码方案 &nbsp; &nbsp; &nbsp;15<br> &nbsp;const PID: Byte; &nbsp;//协议类型 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0<br> &nbsp;const Schedule: PChar; //定时 char[MAX_TIMESTAMP_LEN] &nbsp;''<br> const Expire: PChar; //超时时间 char[MAX_TIMESTAMP_LEN] &nbsp; &nbsp; ''<br> &nbsp;const Default_ID: Longint; //缺省短消息 &nbsp; &nbsp;0<br> &nbsp;const UDHI: Byte; &nbsp;//1表示UD为一个结构,0表示缺省 &nbsp; &nbsp; 0<br> &nbsp;const UDLen: Longint; //表示UD的长度 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 140<br> &nbsp;const UserData: PChar; //用户信息,短消息正文 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'test'<br> &nbsp;const sServiceType: PChar; &nbsp;//业务子类型 by ycl 2001.7.9<br> &nbsp;byMsgID: PChar; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //MAX_MSG_ID,CMPP的字段,消息ID<br> &nbsp;byPKTotal: Byte; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//相同Msg_id的消息总条数,从1开始<br> &nbsp;byPKNumber: Byte; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //相同Msg_id的消息序号,从1开始<br> &nbsp;byMsglevel: Byte; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //信息级别<br> &nbsp;byFeeUserType: Byte; &nbsp; &nbsp; &nbsp; &nbsp;//计费用户类型字段,0:对目的终端MSISDN计费;1:对源终端MSISDN计费;2:对SP计费;3:表示本字段无效<br> &nbsp;sSPID: PChar; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //MAX_SPID_LEN,信息内容来源<br> &nbsp;sFeeType: PChar; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//MAX_FEE_TYPE_LEN,资费类别<br> &nbsp;sFeeAddr: PChar; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//MAX_ADDR_LEN,被计费用户地址<br> &nbsp;sFeeCode: PChar; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//MAX_FEE_CODE_LEN,资费代码<br> &nbsp;byUserNum: PChar; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//接收消息的用户数量<br> &nbsp;sDestAddrs: PChar; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//目的地址,最多100个,CMPP使用<br> &nbsp;SM_ID: PChar; &nbsp; &nbsp; &nbsp;//返回:短消息ID<br> &nbsp;FCS: PChar &nbsp; &nbsp; &nbsp; &nbsp;//返回:失败原因<br> &nbsp;): integer; stdcall; external SMEIDLL;<br><br><br>如下这样可以发送一个号码:<br>procedure TFrmMain.Button1Click(Sender: TObject);<br>var<br> &nbsp; &nbsp;iResult : integer;<br> &nbsp; &nbsp;byMsgID: array[0..22] of Byte; &nbsp; &nbsp; &nbsp;//返回:短消息ID<br> &nbsp; &nbsp;MsgFmt, byUserNum, UDHI : integer;<br> &nbsp; &nbsp;msgLen : Longint;<br> &nbsp; &nbsp;destID, msg, s, spID : string;<br> &nbsp; &nbsp;SM_ID, FCS: PChar;<br> &nbsp; &nbsp;sDestAddrs: PChar;<br>begin<br><br> &nbsp; &nbsp;FillChar(byMsgID, 23, 0);<br> &nbsp; &nbsp;destID := '106920005521001000';<br> &nbsp; &nbsp;msg := '我是一个中国人,上海市.';<br> &nbsp; &nbsp;msgLen := length(msg);<br> &nbsp; &nbsp;MsgFmt := 15;<br> &nbsp; &nbsp;{<br> &nbsp; &nbsp;s := strtohex(msg);<br> &nbsp; &nbsp;msgLen := trunc(length(s)/2);<br> &nbsp; &nbsp;msgBin := hexStrToBin(s);<br> &nbsp; &nbsp;MsgFmt := 4;<br> &nbsp; &nbsp;}<br> &nbsp; &nbsp;spID := '200552';<br> &nbsp; &nbsp;byUserNum := 1;<br> &nbsp; &nbsp;sDestAddrs:= '13800000000';<br> &nbsp; &nbsp;UDHI := 0;<br><br> &nbsp; &nbsp;iResult := corp_SubmitAExEx(Byte(2), Byte(1), PChar(destID), Byte(2), Byte(1), PChar(''), Byte(0), Byte(0), Byte(0), Byte(1), Byte(0), Byte(MsgFmt), Byte(0),<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PChar(''), PChar(''), 0, Byte(UDHI), msgLen, PChar(msg), PChar(''), @byMsgID, Byte(1),<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Byte(1), Byte(0), Byte(2), PChar(spID), PChar('01'), PChar(''), PChar('000000'),<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PChar(byUserNum), sDestAddrs, @SM_ID, @FCS);<br> &nbsp; &nbsp;logit(StrPas(PChar(@byMsgID)));<br>end;<br><br>如何将多个号码放入sDestAddrs进行发送?<br><br>在华为API中sDestAddrs的定义如下<br>byUserNum &nbsp;类型:unsigned char<br> &nbsp;适用协议:CMPP<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;意义:接收消息的用户数量<br>sDestAddrs &nbsp;类型:LPCSTR,21* byUserNum个ASCII字符串<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 适用协议:CMPP<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;意义:接收业务的MSISDN号码,最多100个MSISDN号码。
 
华为API的示例,供参考<br><br> CDemoDlg* p =(CDemoDlg*)lparam;<br> unsigned char OrgTON=1, OrgNPI=1;<br> unsigned char DestTON=1, DestNPI=1;<br> unsigned char PRI, DCS;<br> char sadd[100];<br> char dadd[100];<br> char schedule[100];<br> char expire[100]; <br> &nbsp; &nbsp; &nbsp; unsigned char bySRR; &nbsp;//状态报告标志<br> unsigned long default_id=0;<br> unsigned char UDHI=0;<br> unsigned long UDLen;<br> unsigned long SM_ID;<br> unsigned char FCS;<br> unsigned char PID;<br> <br> ::EnterCriticalSection(&(p-&gt;m_critical));<br><br> PID = (unsigned char)p-&gt;m_pid;<br><br> &nbsp; &nbsp;bySRR = (unsigned char)p-&gt;m_iSRR;<br> switch(p-&gt;m_PRI)<br> {<br> case 0:<br> PRI=SM_PRI_DEFAULT;<br> break;<br> case 1:<br> PRI=SM_PRI_PRIOR;<br> break;<br> };<br> DCS = (unsigned char)atol(p-&gt;m_DCS);<br><br> UDLen=p-&gt;m_len;<br> &nbsp; &nbsp;UDHI = p-&gt;m_UDHI;<br> &nbsp; &nbsp;BOOL IsBinary = p-&gt;m_Binary;<br><br> int size = p-&gt;m_userdata.GetLength();<br><br> char * ud =NULL;<br> ud=new char[size+1];<br> memset(ud, 0, size+1);<br> if (ud == NULL)<br> {<br> ::LeaveCriticalSection(&(p-&gt;m_critical));<br> return -1;<br> };<br><br> &nbsp; &nbsp;if (IsBinary)<br> &nbsp; &nbsp;{<br> &nbsp; &nbsp; &nbsp; &nbsp;AnalysisString(p-&gt;m_userdata, (unsigned char*)ud, size);<br> &nbsp; &nbsp; &nbsp; &nbsp;UDLen = size;<br> &nbsp; &nbsp;}<br> &nbsp; &nbsp;else<br> &nbsp; &nbsp; &nbsp; &nbsp;strcpy(ud,p-&gt;m_userdata);<br><br> strcpy(schedule, p-&gt;m_schedule);<br> strcpy(expire, p-&gt;m_expire);<br> default_id=p-&gt;m_default_id;<br> strcpy(sadd,p-&gt;m_orgaddr);<br> strcpy(dadd,p-&gt;m_destaddr); <br> ::LeaveCriticalSection(&(p-&gt;m_critical));<br><br> CString str;<br> unsigned char byMsgID[23]; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //CMPP的字段,消息ID<br> unsigned char byPKTotal = 0; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //相同Msg_id的 ?⒆芴跏???开始<br> &nbsp; &nbsp; &nbsp; unsigned char byPKNumber = 0; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//相同Msg_id的消息序号,从1开始<br> unsigned char byMsgLevel = 0; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//信息级别<br> unsigned char byFeeUserType = 0; &nbsp; <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//计费用户类型字段,0:对目的终端MSISDN计费;1:对源终端MSISDN计费;<br>// 2:对SP计费;3:表示本字段无效<br> char sSPID[MAX_SPID_LEN]; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//信息内容来源<br> char sFeeType[MAX_FEE_TYPE_LEN]; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //资费类别<br> char sFeeAddr[MAX_ADDR_LEN]; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //被计费用户<br> char sFeeCode[MAX_FEE_CODE_LEN]; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //资费代码<br> unsigned char byUserNum = 0; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //接收消息的用户数<br> char sDestAddrs[MAX_ADDRS_LEN]; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//手机号码集<br> &nbsp; &nbsp; &nbsp; unsigned char sSmgpMsgID[SMGP_MSGID_LEN];<br> unsigned char msgtype;<br> char sFixedFee[MAX_FEE_CODE_LEN];<br><br> memset(byMsgID, 0, 23);<br> memset(sSPID, 0, MAX_SPID_LEN);<br> memset(sFeeType, 0, MAX_FEE_TYPE_LEN);<br> memset(sFeeAddr, 0, MAX_ADDR_LEN);<br> memset(sFeeCode, 0, MAX_FEE_CODE_LEN);<br> memset(sDestAddrs, 0, MAX_ADDRS_LEN); <br> memset(sFixedFee, 0, MAX_FEE_CODE_LEN);<br> memset(sSmgpMsgID, 0, SMGP_MSGID_LEN);<br><br> byPKTotal = p-&gt;m_byPKTotal;<br> byPKNumber = p-&gt;m_byPKNumber;<br> byMsgLevel = p-&gt;m_byMsgLevel;<br> byFeeUserType = p-&gt;m_byFeeUserType;<br> memcpy(sSPID, p-&gt;m_sSPID, MAX_SPID_LEN); <br> memcpy(sFeeType, p-&gt;m_sFeeType, MAX_FEE_TYPE_LEN);<br> memcpy(sFeeAddr, p-&gt;m_sFeeAddr, MAX_ADDR_LEN);<br> memcpy(sFeeCode, p-&gt;m_sFeeCode, MAX_FEE_CODE_LEN);<br> byUserNum = p-&gt;m_byUsrNum;<br> memcpy(sDestAddrs, p-&gt;m_sDestAddrs, MAX_ADDRS_LEN);<br> memcpy(sFixedFee, p-&gt;m_sFixedFee, MAX_FEE_CODE_LEN);<br> msgtype = p-&gt;m_uMsgType;<br><br> int iRet;<br><br> char ServiceSubType[MAX_SERVICE];<br> memcpy(ServiceSubType, p-&gt;m_sServiceType, MAX_SERVICE - 1);<br><br> if(p-&gt;m_protocol == 2) //CMPP协议<br> {<br> iRet = &nbsp;corp_SubmitAExEx(OrgTON,OrgNPI,sadd,DestTON,DestNPI,dadd,PRI,0,0, /<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bySRR,0,DCS,PID,schedule,expire,default_id,UDHI,UDLen, LPCSTR)ud,/<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (LPCSTR)ServiceSubType, byMsgID/*new*/, byPKTotal/*new*/, &nbsp;/<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; byPKNumber/*new*/, byMsgLevel/*new*/, &nbsp;byFeeUserType/*new*/, /<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sSPID/*new*/, sFeeType/*new*/, sFeeAddr/*new*/, sFeeCode/*new*/, &nbsp;/<br> byUserNum/*new*/, sDestAddrs/*new*/, &SM_ID,&FCS);<br> } <br> &nbsp; &nbsp; else if(p-&gt;m_protocol == 6) // SMGP<br> {<br> &nbsp; &nbsp; &nbsp; &nbsp;iRet = corp_SubmitAExExEx(OrgTON,OrgNPI,sadd,DestTON,DestNPI,dadd,PRI,0,0,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bySRR,0,DCS,PID,schedule,expire,default_id, UDHI, UDLen, (LPCSTR)ud, /<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(LPCSTR)ServiceSubType, byMsgID/*new*/, byPKTotal/*new*/, &nbsp;/<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; byPKNumber/*new*/, byMsgLevel/*new*/, &nbsp; &nbsp;byFeeUserType/*new*/, <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sSPID/*new*/, &nbsp; sFeeType/*new*/, sFeeAddr/*new*/, sFeeCode/*new*/, /<br> &nbsp; &nbsp; byUserNum/*new*/, sDestAddrs/*new*/, &nbsp; &SM_ID,&FCS, sSmgpMsgID, /<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; msgtype, sFixedFee);<br> } <br> else<br> {<br> //SMPP协议。<br> if((p-&gt;m_sServiceType).IsEmpty())<br> iRet = corp_ SubmitA(OrgTON,OrgNPI,sadd,DestTON,DestNPI,dadd,PRI,0,0,/<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bySRR,0,DCS,PID,schedule,expire,default_id, UDHI, UDLen, /<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (LPCSTR)ud,&SM_ID,&FCS);<br> else<br> iRet= SubmitAEx(OrgTON,OrgNPI,sadd,DestTON,DestNPI,dadd,PRI,0,0,/<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bySRR,0,DCS,PID, schedule,expire,default_id,UDHI,UDLen, /<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(LPCSTR)ud, (LPCSTR)ServiceSubType, &SM_ID,&FCS); <br> }<br> /*int iRet = VPSubmitSM(sadd, dadd, schedule, expire,<br> default_id, (LPCSTR)ud, &SM_ID);*/<br> if (iRet != E_SUCCESS) <br> {<br> char errstr[200];<br> if (GetErrorString(iRet, 200, errstr) &gt; 0)<br> ::MessageBox(NULL,errstr,&quot;Submit Error Info&quot;, MB_OK| &nbsp;/<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MB_ICONINFORMATION);<br> delete ud;<br> return 0;<br> };<br><br> str.Format(&quot;submit success./n&quot; &quot; &nbsp;SM ID :%u,/n&quot;&quot; &nbsp;FCS &nbsp; :%u.&quot;, SM_ID, FCS);<br> ::MessageBox(NULL,str, &quot;Submit Info&quot;, MB_OK|MB_ICONINFORMATION);<br> delete ud;
 
这个不是很简单的啊<br>byUserNum: PChar; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//接收消息的用户数量<br>sDestAddrs: PChar; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//目的地址,最多100个,CMPP使用<br><br>前面这个是发送的用户数量<br>后面这个把手机号码按要求排起来就行了啊
 
后退
顶部