Cmpp发送wappush

  前一段,给移动做一个wappush的东西,在网上找资料,发现几乎没有,有的也是说的很含糊,最后,尝试了很久,终于解决了,奉献给大家.

(1):使用http://www.codeproject.com/csharp/wappush.asp这里说的方法生成一个16进制的字符串,这个串就是短信内容content.

(2):由于CMPP使用socket发送,因此content需要进行二进制编码,那么如果你采用c#语言,请使用下面的方法,其他语言类同。

public static byte[] hex2Ascii(string s)

         {

 

              int len = s.Length;

 

              byte[] temp = new byte[len/2];

              int j = 0;

              for(int i=0;i<len;i++)

              {

                   string s2 = s.Substring(i,2);

                   string s21 = s2.Substring(0,1);

                   string s22 = s2.Substring(1,1);

                   temp[j]=(byte)(str2byte(s21) * 16 + str2byte(s22));

                   i++;

                   j++;

              }

              return temp;

         }

         public static int str2byte(string ch)

         {

              string aa = ch.ToLower();

              if(aa.Equals("a")) return 10;

              if(aa.Equals("b")) return 11;

              if(aa.Equals("c")) return 12;

              if(aa.Equals("d")) return 13;

              if(aa.Equals("e")) return 14;

              if(aa.Equals("f")) return 15;

              return Convert.ToInt32(aa);

 

         }

(3):在CMPP协议中,在发送WAPPUSH时候,需要将TP_pID设置为0,将TP_udhi设置为64。

(4):test it!

 
    
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值