WAP PUSH(SMS下发)
来源:互联网 发布:如何面试技术总监 知乎 编辑:程序博客网 时间:2024/05/16 09:01
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
- WAP PUSH(SMS下发)
- wap push sms
- Create WAP Push SMS Messages
- [原]Wap push over sms 实践
- Read WAP Push SMS with MAPI
- 如何创建WAP Push SMS Messages
- WAP PUSH的SMS PDU解析
- 如何通过CMPP短信网关下发WAP PUSH
- Create WAP Push SMS Messages (From C# to JAVA)
- WAP PUSH解析(1)——SMS PDU编码
- Android SMS intercept without notification icon or WAP-PUSH messages
- WAP PUSH解析(1)——SMS PDU编码
- How to code a WAP Push message over SMS
- Create WAP Push SMS Messages By Adam Bird
- sms实现wap push的方法和格式
- WAP PUSH解析(1)——SMS PDU编码
- Sending SMS WAP Push messages using the ActiveXperts SMS and MMS Toolkit.
- wap push
- UTF-8 and Unicode FAQ
- hibernate基础知识备份
- 一篇男人必看的雄文(转载)
- 值得用一生来品味的100句凡人语录 --转载
- 五句对你的人生管用的话 --转载
- WAP PUSH(SMS下发)
- 改变人生的32句励志名言--转载
- 英语十句--转载
- JCL中由接口获得对象的方法
- 基础排序算法
- 人际关系--转载
- 感悟人生秘诀 --转载
- 我的大学十年--转载
- 问题求教