只能利用VBS发送短信-创新互联
这篇文章主要介绍了只能利用VBS发送短信,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。
为新田等地区用户提供了全套网页设计制作服务,及新田网站建设行业解决方案。主营业务为成都做网站、成都网站设计、新田网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!代码如下:
m = "xxxyyyyzzzz" '手机号码
pass = "12345678" '登陆密码
msg = "Hello world" '飞信内容
Const online = 1 '在线
Const busy = 2 '忙碌
Const away = 3 '离开
Const hidden = 4 '隐身
Dim http
Set http = CreateObject("Msxml2.XMLHTTP")
http.open "POST", "http://f.10086.cn/im/login/inputpasssubmit1.action", False
http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
http.send "m=" & m & "&pass=" & pass & "&loginstatus=" & hidden '隐身登陆
wml = http.responseText
If InStr(wml, "密码输入错误") Then
WScript.Echo "对不起,密码输入错误,请重新输入!"
WScript.Quit '登陆失败,退出程序
End If
http.open "POST", "http://f.10086.cn/im/user/sendMsgToMyselfs.action", False
http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
http.send "msg=" & msg '给自己的手机发短信
wml = http.responseText
If InStr(wml, "发送成功") Then WScript.Echo "发送成功"
http.open "GET", "http://f.10086.cn/im/index/logoutsubmit.action", False
http.send '注销登陆
这里只是一个示例,至于怎么给别人发短信和飞信,自己琢磨吧。本来想写一个像 PyFetion 那样的 VbsFetion 的,但是想想没什么意义,这样还不如直接装个飞信 PC 客户端,于是就不折腾的,喜欢折腾的同学可以继续。
上面的程序可以很轻松地改写成其他语言,C、C++、C#、Java、JavaScript、Python、Perl、Ruby、Lua、PHP……用这个接口可以做很多有趣的事情,不是吗?
VBS短信飞信发送类(VBSFetion)
本来想把昨天《用VBS发送短信(飞信)》里的 VBS 程序改写成 PHP 的,不过为了不重复造轮子,事先 Google 了一下,发现已经有人实现了,详见PHP飞信发送类(PHPFetion)v1.2发布。好吧,既然已经有人把它封装成 PHP 类了,我就封装一个 VBS 类吧。
代码如下:
Class VBSFetion
Private [$mobile], [$password], http
'Author: Demon
'Website: /tupian/20230522/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 Function
End Class
示例程序:
'初始对象
Set fetion = New VBSFetion
'登陆飞信
If fetion.Init("11122223333", "123456") Then
'发送飞信
fetion.SendMsg "44455556666", "Hello world"
'发送短信
fetion.SendShortMsg "77788889999", "Hello world"
End If
感谢你能够认真阅读完这篇文章,希望小编分享的“只能利用VBS发送短信”这篇文章对大家有帮助,同时也希望大家多多支持创新互联网站建设公司,,关注创新互联行业资讯频道,更多相关知识等着你来学习!
当前名称:只能利用VBS发送短信-创新互联
当前网址:http://pwwzsj.com/article/pgeic.html