WAP PUSH(SMS下发)

package sjsw.bean;
class SMSPush
{
    public SMSPush()
    {
           
    }
    public static String getSMSPush(String url,String subject)
    {
            //0B05040B8423F00003030101
            //29060603AE81EA8DA002056A0045C6080C03
            //URL:::7777772E67646363742E676F762E636E2F736A7377776170
            //000103
            //CONTENT:::E7B2BEE5BDA9E697A0E999902CE5B0BDE59CA8E782ABE692AD
            //000101
            String sUdh1="0B05040B8423F00003B30201";
            String sUdh2="0B05040B8423F00003B30202";
        String sPdu = "29060603AE81EA8DCA02056A0045C6080C03";
        String sUrl = "";
        try
        {
                sUrl = byteArrayToHexString(url.getBytes());
                System.out.println("url:::::::::"+sUrl);
        }
        catch (Exception ex)
        {
        }
        String urlend = "000103";
        String sMsg = "";
        try
        {
                sMsg= byteArrayToHexString(subject.getBytes("UTF-8")); //显示给用户的内容,用utf-8编码。utf-8编码,英文字符直接用ascii码;中文如果unicode是(二进制)
                System.out.println("msg::::::::::"+sMsg);
        }
        catch (Exception ex)
        {
        }
        String sEnd = "000101";
        System.out.println("**********************************1");
        String pushString1="";
        String pushString2="";
        String pushString="";
        if((sUrl+urlend+sMsg).length()<216)
        {
                pushString= sUdh1 + sPdu + sUrl + urlend + sMsg + sEnd;
        }
        else
        {
                String all = sUrl + urlend + sMsg + sEnd;
                String part1=all.substring(0,216);
                String part2=all.substring(216,all.length());
                pushString1= sUdh1 +  sPdu   + part1 +";";
                pushString2= sUdh2    + part2 +";";
                pushString = pushString1 + pushString2;       
        }
        System.out.println("pushString:::::::"+pushString);
        return pushString;
    }
    public static String getSMSPhone(String phone)
    {
            String phone_temp=byteArrayToHexString(phone.getBytes());
            return phone_temp;
    }
    public static String byteArrayToHexString(byte b[])
    {
        String result = "";
        for (int i = 0; i < b.length; i++)
        {
            result = result + byteToHexString(b[i]);
        }
        return result;
    }
    public static String byteToHexString(byte b)
    {
        int n = b;
        if (n < 0)
        {
            n = 256 + n;
        }
        int d1 = n / 16;
        int d2 = n % 16;
        return HexCode[d1] + HexCode[d2];
    }
    private static String HexCode[] ={"0", "1", "2", "3", "4", "5", "6", "7", "8", "9","A", "B", "C", "D", "E", "F"};
}
本篇文章可以判断url和宣传语是否超长,如果超长则分成两个包下发,已经用诺基亚3100成功测试。
参考文章:http://blog.csdn.net/cutemouse/archive/2006/12/29/1466969.aspx 
 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值