新收集的WAPPUSH代码,并经过改造
package com.wap;
import java.io.IOException;
import java.sql.Date;
public class WapPush
{
public int sendSMS(String[] mobile_nos, byte[] msg)
{
。。。。
return 0;
}
public static String getSMSPush(String url, String subject, String startTime,
String endTime)
{
String pushString = "";
String body = "";
body += "02";
body += "05"; //-//WAPFORUM//DTD SI 1.0//EN
body += "6A"; //UTF-8
body += "00"; //字符串结�?
body += "45"; //<si>
body += "C6"; //<indication
body += "08"; //<action=signal-high>
body += "0C"; //href="http://
body += "03"; //字符串开�?
body += byteArrayToHexString(url.getBytes()); //实际地址
body += "00"; //字符串结�?
body += "0A"; //created=
body += "C3"; //'时间
body += "07"; //时间字节�?
body += startTime; //YYYYMMDDHHMMSS
body += "10"; //si_expires=
body += "C3"; //时间
body += "07"; //时间字节�?
body += endTime; //YYYYMMDDHHMMSS
body += "01"; //>
body += "03"; //字符串开�?
try
{
body += byteArrayToHexString(subject.getBytes("utf-8")); //显示给用户的内容,用utf-8编码。utf-8编码,英文字符直接用ascii码;中文如果unicode是(二进制)
}
catch (Exception ex)
{
}
body += "00"; //字符串结�?
body += "01"; //</indication>"
body += "01"; //'</si>
int length = body.length();
String pud = "";
pud += "81"; //transaction id (connectionless WSP)
pud += "06"; //'pdu type (06=push)
pud += "06"; //Headers len
pud += "03";
pud += "AE";
pud += "81";
pud += "EA"; //content type: application/vnd.wap.sic; charset=utf-8
pud += "8D"; //content-length
pud += Integer.toHexString(length).toUpperCase();
String udh = "";
udh += "06"; //User Data Header Length (6 bytes)
udh += "05"; //UDH Item Element id (Port Numbers)
udh += "04"; //UDH IE length (4 bytes)
udh += "0B";
udh += "84"; //destination port number
udh += "23";
udh += "F0"; //origin port number
pushString = udh + pud + body;
System.out.println(pushString);
return pushString;
}
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 byteToString(byte b[])
{
String result = "";
for (int i = 0; i < b.length; i++)
{
result = result + 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"
};
private static String getUTFString(final String gbString)
{
if (gbString == null)
return "";
char[] utfBytes = gbString.toCharArray();
String unicodeBytes = "";
for (int byteIndex = 0; byteIndex < utfBytes.length; byteIndex++)
{
String hexB = "";
if (utfBytes[byteIndex] < '!')
{
hexB = Integer.toHexString(utfBytes[byteIndex]);
if (hexB.length() <= 2)
{
hexB = "00" + hexB;
}
unicodeBytes = unicodeBytes + "&#x" + hexB + ";";
}
else
{
unicodeBytes += utfBytes[byteIndex];
}
}
return unicodeBytes;
}
public static int StringToByte(String str)
{
int ret = 0;
for(int i=0;i<HexCode.length;i++)
{
if(HexCode[i].equalsIgnoreCase(str))
return i;
}
return ret;
}
public static byte[] stringToBytes(String str)
{
if(str==null||str.equals(""))
return null;
byte[] bytes = new byte[str.length()/2];
for(int i=0;i<bytes.length;i++)
{
String high = str.substring(i*2,i*2+1);
String low = str.substring(i*2+1,i*2+2);
bytes[i] = (byte) (StringToByte(high)*16 + StringToByte(low));
}
return bytes;
}
public static void main(String[] args)
{
WapPush wp= new WapPush();
String[] mobile_nos = {"13812345678"};
int i = wp.sendSMS(mobile_nos,
WapPush.stringToBytes(
WapPush.getSMSPush("wap.monternet.com","monternet",
new java.text.SimpleDateFormat("yyyyMMdd").format(new Date(System.currentTimeMillis())),
new java.text.SimpleDateFormat("yyyyMMdd").format(new Date(System.currentTimeMillis()))
)));
}
}
新收集的WAPPUSH代码,并经过改造相关推荐
- Gartner:70%新应用由低代码开发,AI热潮后小数据崛起
作者 | 宋慧 出品 | CSDN云计算 头图 | 付费下载于东方IC 国际研究机构Gartner在近日发布了2021年十大数据和分析趋势.纵观这十个趋势,基本可以归纳为三类主题,分别是: 加速数据和 ...
- 企业数字化新战场:低代码究竟是“毒瘤”还是“良药”?
这篇是技术领导力公众号创始人--Mr.K先生直播的文字摘录,这场直播获得了满堂喝彩,讲的非常好,整篇文章大概4000字,建议大家看完. 来源:Mr.K-<帆软·决胜数字化转型>直播 文章整 ...
- UIUC同学Jia-Bin Huang收集的计算机视觉代码合集(ZZ)
UIUC同学Jia-Bin Huang收集的计算机视觉代码合集(ZZ) 链接如下: http://www.cnblogs.com/idaidai/archive/2012/03/01/2375800. ...
- 收集的开源代码下载网站
收集的开源代码下载网站 1.源码之家 2.代码中国网 3.源码天下 4.站长网 5.源码网 6.中国站长下载-源码下载 7.ASP300 8.ASP酷程序下载中心 9.洪越源代码 10.114软件源码 ...
- 新技能 | 使用python代码来高效操作Excel表格 (文末赠书5本)
新技能 | 使用python代码来高效操作Excel表格 (文末赠书5本) 在日常学习和工作中,少不了要跟Excel表格打交道.而我们作为程序猿,深知代码编程给人带来的便捷性,那我们怎么样使用代码来操 ...
- 旧瓶装“新酒”?无代码开发是炒作噱头,还是大势所趋?
无代码也能进行软件开发吗?如果这是在20世纪,你提出这样一个问题,肯定会被当成"异类". 但现在不同了,现在是"实践求真知"的21世纪,IT界任何新奇技术,只要 ...
- IDEA 新特性:提前知道代码怎么走
点击上方"方志朋",选择"设为星标" 回复"666"获取新整理的面试文章 新特性 IDEA - 2020.1 版本针对调试器和代码分析器的改 ...
- 这些年,我收集的JavaScript代码(二)
一.JavaScript跨平台事件 对于跨平台事件我们一般这么写(只例举添加事件): functionaddEventHandler(oTarget, sEventType, fnHandler){i ...
- 打开新窗口的js代码
1,打开新窗口全屏 HTML代码 <SCRIPT> function ow(owurl){ var tmp=window.open("about:blank",&quo ...
最新文章
- android闪退比ios多,安卓和苹果多年使用后有什么区别?一个易卡顿,一个易闪退...
- 统计学习方法第五章作业:ID3/C4.5算法分类决策树、平方误差二叉回归树代码实现
- Extjs 动态生成表格
- 曝光:一位来自微软公司的粉丝 写给我的信
- Linux系统安装完成后创建交换空间
- 【CCCC】L3-018 森森美图 (30分),计算几何+判断三点共线+bfs最短路
- Wannafly挑战赛22: C. 多项式(大整数)
- 为/tmp添加nodev/nosuid/noexec挂载选项
- CAD中如何插入图框?CAD插入图框方法教程
- C语言qsort()函数用法总结
- chrome扩展开发与上架
- 钉钉和mis系统对接调研
- DataWhale组队学习——DCIC赛事 task1
- wpscan扫描的简单介绍(对WordPress的扫描CMS)
- CDOJ1059-秋实大哥与小朋友
- latex解决存在/任意/非符号如何打
- java如何写出简洁代码
- 37岁985老兵,小公司朝九晚五,大龄底层没机会了!
- 一张图分出你是左脑发达还是右脑发达(转)
- 团队成员梁飞专访:阿里巴巴分布式服务框架Dubbo