VBS短信飞信发送类(VBSFetion)
来源:互联网 发布:c 二维数组赋值不全 编辑:程序博客网 时间:2024/04/28 13:49
VBS短信飞信发送类(VBSFetion)
标签: Fetion, VB, VBS, VBScript, VBSFetion, 短信, 飞信
标题: VBS短信飞信发送类(VBSFetion)
作者: Demon
链接: http://demon.tw/my-work/vbsfetion.html
版权: 本博客的所有文章,都遵守“署名-非商业性使用-相同方式共享 2.5 中国大陆”协议条款。
本来想把昨天《用VBS发送短信(飞信)》里的 VBS 程序改写成 PHP 的,不过为了不重复造轮子,事先 Google 了一下,发现已经有人实现了,详见PHP飞信发送类(PHPFetion)v1.2发布。好吧,既然已经有人把它封装成 PHP 类了,我就封装一个 VBS 类吧。
Class VBSFetion Private [$mobile], [$password], http 'Author: Demon 'Website: http://demon.tw 'Date: 2011/6/11 '初始化事件 Private Sub Class_Initialize Set http = CreateObject("Msxml2.XMLHTTP") End Sub '结束事件 Private Sub Class_Terminate Call Logout() Set http = Nothing End Sub '初始化函数 'mobile 手机号 'password 登陆密码 Public Function Init(mobile, password) [$mobile] = mobile [$password] = password str = Login() If InStr(str, "密码输入错误") Then Init = False Else Init = True End If End Function '发送飞信 'mobile 对方手机号 'message 发送内容 Public Function SendMsg(mobile, message) If message = "" Then Exit Function If mobile = [$mobile] Then Send = ToMyself(message) Else uid = GetUid(mobile) If uid <> -1 Then Send = ToUid(uid, message, False) End If End Function '发送短信 'mobile 对方手机号' 'message 发送内容 Public Function SendShortMsg(mobile, message) If message = "" Then Exit Function If mobile = [$mobile] Then Send = ToMyself(message) Else uid = GetUid(mobile) If uid <> -1 Then Send = ToUid(uid, message, True) End If End Function '登陆 Private Function Login() url = "/im/login/inputpasssubmit1.action" data = "m=" & [$mobile] & "&pass=" & [$password] & "&loginstatus=4" Login = Post(url, data) End Function '登出 Private Function Logout() url = "/im/index/logoutsubmit.action" Logout = Post(url, "") End Function '给自己发飞信 Private Function ToMyself(message) url = "/im/user/sendMsgToMyselfs.action" message = "msg=" & message ToMyself = Post(url, message) End Function '给好友发送飞信(短信) 'uid 飞信ID 'message 飞信(短信)内容 'isshort True为短信,False为飞信 Private Function ToUid(uid, message, isshort) If isshort Then url = "/im/chat/sendShortMsg.action?touserid=" & uid data = "msg=" & message Else url = "/im/chat/sendMsg.action?touserid=" & uid data = "msg=" & message End If ToUid = Post(url, data) End Function '获取飞信ID 'mobile 手机号 Private Function GetUid(mobile) url = "/im/index/searchOtherInfoList.action" data = "searchText=" & mobile str = Post(url, data) Set re = New RegExp re.Pattern = "/toinputMsg\.action\?touserid=(\d+)" If re.Test(str) Then Set ms = re.Execute(str) GetUid = ms.Item(0).Submatches(0) Else GetUid = -1 End If End Function '发送HTTP POST请求 Private Function Post(url, data) url = "http://f.10086.cn" & url http.open "POST", url, False http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" http.send data Post = http.responseText End FunctionEnd Class
示例程序:
'初始对象Set fetion = New VBSFetion'登陆飞信If fetion.Init("11122223333", "123456") Then '发送飞信 fetion.SendMsg "44455556666", "Hello world" '发送短信 fetion.SendShortMsg "77788889999", "Hello world"End If
0 0
- VBS短信飞信发送类(VBSFetion)
- VBS短信飞信发送类(VBSFetion)
- 代替飞信发送短信
- 飞信api类文件以及发送短信实例
- 飞信免费发送短信接口
- 使用飞信API 发送 短信
- JAVA利用飞信接口发送短信
- python 发送飞信-短信接口
- Python调用飞信接口发送短信
- Python调用飞信接口发送短信
- JAVA利用飞信接口发送短信
- java利用飞信接口发送短信
- Python调用飞信接口发送短信
- Python向飞信好友发送短信
- 发送飞信免费短信API
- 飞信发送免费短信的api
- Android短信发送流程之长短信发送(原)
- Android短信发送流程之长短信发送(原)
- 微积分和数学分析引论(一)——函数
- hdoj2001解题报告
- 2014年值得关注的9项技术
- <<C++Primer PLus 第五版>>读书笔记2
- 函数
- VBS短信飞信发送类(VBSFetion)
- 移动产品设计的八大设计原则
- 修道士和野人
- 最近的学习小结
- Unity3D开发之游戏破解以及游戏数据篡改
- 黑马程序员_程序员必知8大排序
- 开始写点东西
- 黑马程序员-IO包中的常用类案例
- <<C++Primer PLus 第五版>>读书笔记1