VB用COM口发WAPPUSH,返回+CMS ERROR: 500

给出代码如下:

Type WAPPushPDUStruct
    SMSCLen As String
    SMSCType As String
    SMSC As String
    PROTOCOL As String
    TPMRBase As String
    RePhoneNumLen As String
    RePhoneNumType As String
    RePhoneNum As String
   
    TPPID As String
    TPDSC As String
    TPVP As String
    MSGLen As String
   
    WAPPUSHHeadLen As String
    WAPPUSHFlag As String
    DATALen As String
    WAPPUSHCOMBFlag As String
    Total As String
    MSGID As String
    WapPushUDH As String
    WapPushPUD As String
   
'    WAPPUSHBegin As String
'    WSP As String
'    Flag As String
'    DTDSIFlag As String
'    UTF As String
'    FlagBegin As String
   
'    SIBegin As String
'
'    IndicationBegin As String
'
'    Action As String
'    Href As String
'    HrefBegin As String
   
    WapPushIndicator As String
   
    URL As String
   
   
'    HrefEnd As String
'    Split As String
'    TitleBegin As String
   
    WapPushDisplayTextHeader As String
   
    title As String
   
'    TitleEnd As String
'    SIEnd As String
'    IndicationEnd As String
    EndOfWapPush As String
   

       
    PDULen As Integer
    PDU As String
   
End Type

 

Public Function genWapPushPdu(ByVal URL As String, ByVal title As String, ByVal SMSC As String, ByVal phoneNum As String) As WAPPushPDUStruct

    Dim wapPush As WAPPushPDUStruct
   
   
   
    With wapPush
'        .SMSCLen
'        .SMSCType
        .SMSC = SMSC
        .PROTOCOL = "51"
        .TPMRBase = "00"
'        .RePhoneNumLen
'        .RePhoneNumType
        .RePhoneNum = phoneNum
       
       
        FormatPhoneNum .SMSC, .SMSCType
        .SMSCLen = Int2HexStr(Len(.SMSC & .SMSCType) / 2)  '短信息中心地址长度。(短信息中心号码类型 + 短信息中心号码长度 /2 的十六进制表示)
   
    ' msg.DestPhoneNumType 被叫号码类型。有+86时候为"91",否则为"81"
        .RePhoneNumLen = Int2HexStr(FormatPhoneNum(.RePhoneNum, .RePhoneNumType))    ''被叫号码长度。被叫号码长度的十六进制表示。
           
           
        .TPPID = "00"
'        .TPDSC = "A6"
        .TPDSC = "04"   '用户信息编码方式 F5
        .TPVP = "A7"
'        .TPVP = "FF"
'        .MSGLen

'
'         Dim Push_head1, Push_head2 As String
'
'        Push_head1 = "0B05040B8423F00003030101"
'        Push_head2 = "29060603AE81EA8DCA" ' //      81EA8D98 02 06 6A 00 85 09 03
       
       
        .WAPPUSHHeadLen = "0B"
       
        '以下内容在UDH后面
        .WAPPUSHFlag = "00"
        .DATALen = "03"
        .WAPPUSHCOMBFlag = "03"
        .Total = "01"
        .MSGID = "01"
       
        '格式1
'        .WapPushUDH = "0605040B8423F0"
'        .WapPushPUD = "81060603AE81EA8D00"  ' //最后一位为WBXML长度;
'        .WapPushIndicator = "02056A0045C6080C03"
'格式2
'.WapPushUDH = "0605040B8423F0"
'.WapPushPUD = "010603AE8DC4"
'.WapPushIndicator = "02056A0045C6080C03"
'
'格式3
'
'.WapPushUDH = "0B05040B8423F00003030101"
'.WapPushPUD = "29060603AE81EA8DCA"
'.WapPushIndicator = "02056A0045C6080C03"
'
''格式4
''//比老赵帮本多了一个,在这里;//不成功;
'.WapPushUDH="0605040b8423f0"
'.WapPushPUD="250601ae"
'.WapPushIndicator="02056a0045C6080C03"
'
''格式5
'.WapPushUDH="0605040b8423f0"
'.WapPushPUD="250601ae"
'.WapPushIndicator="01056a0045C60C03"'//老赵版本;不成功
'
'格式6
.WapPushUDH = "0605040b8423f0"
.WapPushPUD = "250601ae"
.WapPushIndicator = "02056a0045C60C0"
'
''格式7
'.WapPushUDH="0605040B8423F0"
'.WapPushPUD="72060a03AE81EAaf828D"'//最后一位为WBXML长度;
'.WapPushIndicator="80b48402056A0045C60C03"
'.WapPushDisplayTextHeader="00080103"
'
''格式8
'.WapPushUDH="0B05040B8423F00003030101"
'.WapPushPUD="29060603AE81EA8DCA"'//最后一位为WBXML长度;
'.WapPushIndicator="02056A0045C60C03"
'.WapPushDisplayTextHeader="00080103"
'
''格式9
'.WapPushUDH="0605040b8423f0"
'.WapPushPUD="81060803ae81eab4848d"'//最后一位为WBXML长度;
'.WapPushIndicator="02056A0045C6080C03"
        .WapPushDisplayTextHeader = "000103"
        .EndOfWapPush = "000101"
       
       
'        .URL = GB2Unicode(URL)
        .URL = Str2HexStr(URL)
       
       
'        .title = GB2Unicode(title)

        .title = Str_UTF_8(title, "HEX")


       
       
        Dim str1, str2 As String
        '=======================================================================================================================================
       
        str1 = .SMSCLen & .SMSCType & .SMSC & .PROTOCOL & .TPMRBase & .RePhoneNumLen & .RePhoneNumType & .RePhoneNum & .TPPID & .TPDSC & .TPVP
       

'        str1 = .SMSCLen & .SMSCType & .SMSC & "11" & .RePhoneNumLen & .RePhoneNumType & .RePhoneNum & .TPPID & .TPDSC & .TPVP  '短信消息头,按照正常短信
       

'
        str2 = .WapPushUDH & .WapPushPUD & .WapPushIndicator & .URL & .WapPushDisplayTextHeader & .title & .EndOfWapPush
        

        .MSGLen = Int2HexStr(Len(str2) / 2)
'        .MSGLen = Int2HexStr(Len(.URL) + Len(.title) + 1)
       
        .PDU = str1 & .MSGLen & str2

       
'        .PDULen = Len(.PDU) / 2
       
        .PDULen = Len(.PDU) / 2 - 9
       

'        .PDULen = Len(.PDU) / 2 - 1
       
    End With
    genWapPushPdu = wapPush
End Function

 

你可能感兴趣的:(VB用COM口发WAPPUSH,返回+CMS ERROR: 500)