這篇文章主要介紹了只能利用VBS發(fā)送短信,具有一定借鑒價(jià)值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。
為新田等地區(qū)用戶提供了全套網(wǎng)頁(yè)設(shè)計(jì)制作服務(wù),及新田網(wǎng)站建設(shè)行業(yè)解決方案。主營(yíng)業(yè)務(wù)為成都做網(wǎng)站、成都網(wǎng)站設(shè)計(jì)、新田網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠(chéng)的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會(huì)得到認(rèn)可,從而選擇與我們長(zhǎng)期合作。這樣,我們也可以走得更遠(yuǎn)!代碼如下:
m = "xxxyyyyzzzz" '手機(jī)號(hào)碼
pass = "12345678" '登陸密碼
msg = "Hello world" '飛信內(nèi)容
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, "密碼輸入錯(cuò)誤") Then
WScript.Echo "對(duì)不起,密碼輸入錯(cuò)誤,請(qǐng)重新輸入!"
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 '給自己的手機(jī)發(fā)短信
wml = http.responseText
If InStr(wml, "發(fā)送成功") Then WScript.Echo "發(fā)送成功"
http.open "GET", "http://f.10086.cn/im/index/logoutsubmit.action", False
http.send '注銷登陸
這里只是一個(gè)示例,至于怎么給別人發(fā)短信和飛信,自己琢磨吧。本來(lái)想寫一個(gè)像 PyFetion 那樣的 VbsFetion 的,但是想想沒什么意義,這樣還不如直接裝個(gè)飛信 PC 客戶端,于是就不折騰的,喜歡折騰的同學(xué)可以繼續(xù)。
上面的程序可以很輕松地改寫成其他語(yǔ)言,C、C++、C#、Java、JavaScript、Python、Perl、Ruby、Lua、PHP……用這個(gè)接口可以做很多有趣的事情,不是嗎?
VBS短信飛信發(fā)送類(VBSFetion)
本來(lái)想把昨天《用VBS發(fā)送短信(飛信)》里的 VBS 程序改寫成 PHP 的,不過(guò)為了不重復(fù)造輪子,事先 Google 了一下,發(fā)現(xiàn)已經(jīng)有人實(shí)現(xiàn)了,詳見PHP飛信發(fā)送類(PHPFetion)v1.2發(fā)布。好吧,既然已經(jīng)有人把它封裝成 PHP 類了,我就封裝一個(gè) 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
'結(jié)束事件
Private Sub Class_Terminate
Call Logout()
Set http = Nothing
End Sub
'初始化函數(shù)
'mobile 手機(jī)號(hào)
'password 登陸密碼
Public Function Init(mobile, password)
[$mobile] = mobile
[$password] = password
str = Login()
If InStr(str, "密碼輸入錯(cuò)誤") Then
Init = False
Else
Init = True
End If
End Function
'發(fā)送飛信
'mobile 對(duì)方手機(jī)號(hào)
'message 發(fā)送內(nèi)容
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
'發(fā)送短信
'mobile 對(duì)方手機(jī)號(hào)
' 'message 發(fā)送內(nèi)容
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
'給自己發(fā)飛信
Private Function ToMyself(message)
url = "/im/user/sendMsgToMyselfs.action"
message = "msg=" & message
ToMyself = Post(url, message)
End Function
'給好友發(fā)送飛信(短信)
'uid 飛信ID
'message 飛信(短信)內(nèi)容
'isshort True為短信,F(xiàn)alse為飛信
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 手機(jī)號(hào)
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
'發(fā)送HTTP POST請(qǐng)求
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
示例程序:
'初始對(duì)象
Set fetion = New VBSFetion
'登陸飛信
If fetion.Init("11122223333", "123456") Then
'發(fā)送飛信
fetion.SendMsg "44455556666", "Hello world"
'發(fā)送短信
fetion.SendShortMsg "77788889999", "Hello world"
End If
感謝你能夠認(rèn)真閱讀完這篇文章,希望小編分享的“只能利用VBS發(fā)送短信”這篇文章對(duì)大家有幫助,同時(shí)也希望大家多多支持創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司,,關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,更多相關(guān)知識(shí)等著你來(lái)學(xué)習(xí)!
當(dāng)前名稱:只能利用VBS發(fā)送短信-創(chuàng)新互聯(lián)
分享鏈接:http://muchs.cn/article2/pgeic.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供做網(wǎng)站、全網(wǎng)營(yíng)銷推廣、品牌網(wǎng)站設(shè)計(jì)、企業(yè)建站、自適應(yīng)網(wǎng)站、建站公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容