CMPP下发WAPPUSH编码转换

//短信WAPPUSH编码UNICODE转UTF-8
String WapPushUrl = "wap.test.com";
String WapPushDisplayText = "测试";
try {      
      //转UTF-8编码
      byte[] bWapPushUrl = WapPushUrl.getBytes("UTF-8");
      byte[] bWapPushDisplayText = WapPushDisplayText.getBytes("UTF-8");
      
      //固定格式WapPushHeader1,WapPushHeader2,WapPushIndicator,WapPushDisplayTextHeader,EndOfWapPush
      byte[] WapPushHeader1 = { 0x0B, 0x05, 0x04, 0x0B, (byte) 0x84,
        0x23, (byte) 0xF0, 0x00, 0x03, 0x03, 0x01, 0x01 };      
      byte[] WapPushHeader2 = { 0x29, 0x06, 0x06, 0x03, (byte) 0xAE,
        (byte) 0x81, (byte) 0xEA, (byte) 0x8D, (byte) 0xCA };      
      byte[] WapPushIndicator = { 0x02, 0x05, 0x6A, 0x00, 0x45,
        (byte) 0xC6, 0x0C, 0x03 };      
      byte[] WapPushDisplayTextHeader = {0x00, 0x01, 0x03};
      byte[] EndOfWapPush = { 0x00, 0x01, 0x01 };
      
      //WapPush消息內容填充顺序:
      //WapPushHeader1,WapPushHeader2,WapPushIndicator,
      //WapPushUrl,WapPushDisplayTextHeader,WapPushDisplayText,EndOfWapPush

      byte[] Content = new byte[12 + 9 + 8 + bWapPushUrl.length
        + 3 + bWapPushDisplayText.length + 3];

      int pos = 0;
      //填充WapPushHeader1
      System.arraycopy(WapPushHeader1, 0, Content, pos,
        WapPushHeader1.length);
      pos = WapPushHeader1.length;
      //填充WapPushHeader2
      System.arraycopy(WapPushHeader2, 0, Content, pos,
        WapPushHeader2.length);
      pos += WapPushHeader2.length;
      //填充WapPushIndicator
      System.arraycopy(WapPushIndicator, 0, Content, pos,
        WapPushIndicator.length);
      pos += WapPushIndicator.length;
      //填充WapPushUrl
      System.arraycopy(bWapPushUrl, 0, Content, pos,
        bWapPushUrl.length);
      pos += bWapPushUrl.length;
      //填充WapPushDisplayTextHeader
      System.arraycopy(WapPushDisplayTextHeader, 0, Content, pos,
        WapPushDisplayTextHeader.length);
      pos += WapPushDisplayTextHeader.length;
      //填充WapPushDisplayText
      System.arraycopy(bWapPushDisplayText, 0, Content, pos,
        bWapPushDisplayText.length);
      pos += bWapPushDisplayText.length;
      //填充EndOfWapPush
      System.arraycopy(EndOfWapPush, 0, Content, pos,
        EndOfWapPush.length);
} catch (Exception e) {
      e.printStackTrace();
}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值