佳木斯湛栽影视文化发展公司

主頁 > 知識(shí)庫 > 利用VBS發(fā)送短信的實(shí)現(xiàn)代碼(通過飛信)

利用VBS發(fā)送短信的實(shí)現(xiàn)代碼(通過飛信)

熱門標(biāo)簽:銀行業(yè)務(wù) 智能手機(jī) 網(wǎng)站文章發(fā)布 鐵路電話系統(tǒng) 美圖手機(jī) 檢查注冊表項(xiàng) 呼叫中心市場需求 服務(wù)器配置
光看標(biāo)題就已經(jīng)覺得很牛逼了,聽說過可以用 PHP 發(fā)送短信(飛信),也使用過 Python 實(shí)現(xiàn)的 PyFetion 發(fā)送過短信(飛信)。我也看過對(duì)應(yīng)的 PHP 和 Python 源碼,實(shí)現(xiàn)起來還是比較復(fù)雜的,難道可以用 VBS 來實(shí)現(xiàn)?

看到代碼后更覺得牛逼,竟然是使用 10086.cn (移動(dòng)官網(wǎng))上面的接口來實(shí)現(xiàn)的,飛信官方難道已經(jīng)公布飛信接口了?若不是,難道是代碼的作者自己發(fā)現(xiàn)的接口?那也太強(qiáng)大了!Google 了一下才發(fā)現(xiàn),哦,都不是,而是 WAP 飛信。像我這種還在用著 2005 年生產(chǎn)的只能打電話發(fā)短信的手機(jī)的生活在石器時(shí)代的人,當(dāng)然不知道 WAP 飛信的存在。我現(xiàn)在連短信都很少發(fā),更不用說飛信了,我已經(jīng)不記得上一次登陸飛信是什么時(shí)候。
復(fù)制代碼 代碼如下:

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ò)誤,請重新輸入!"
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ā)短信和飛信,自己琢磨吧。本來想寫一個(gè)像 PyFetion 那樣的 VbsFetion 的,但是想想沒什么意義,這樣還不如直接裝個(gè)飛信 PC 客戶端,于是就不折騰的,喜歡折騰的同學(xué)可以繼續(xù)。
上面的程序可以很輕松地改寫成其他語言,C、C++、C#、Java、JavaScript、Python、Perl、Ruby、Lua、PHP……用這個(gè)接口可以做很多有趣的事情,不是嗎?

VBS短信飛信發(fā)送類(VBSFetion)

本來想把昨天《用VBS發(fā)送短信(飛信)》里的 VBS 程序改寫成 PHP 的,不過為了不重復(fù)造輪子,事先 Google 了一下,發(fā)現(xiàn)已經(jīng)有人實(shí)現(xiàn)了,詳見PHP飛信發(fā)送類(PHPFetion)v1.2發(fā)布。好吧,既然已經(jīng)有人把它封裝成 PHP 類了,我就封裝一個(gè) VBS 類吧。
復(fù)制代碼 代碼如下:

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
'結(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請求
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

來源: http://demon.tw/my-work/vbsfetion.html
您可能感興趣的文章:
  • C#代碼實(shí)現(xiàn)短信驗(yàn)證碼接口示例
  • C#怎么實(shí)現(xiàn)手機(jī)短信發(fā)送功能
  • java、php、C#、asp實(shí)現(xiàn)短信群發(fā)功能的方法
  • CDMA 貓用AT命令發(fā)中文短信(C#)
  • 基于JavaScript實(shí)現(xiàn)手機(jī)短信按鈕倒計(jì)時(shí)(超簡單)
  • php發(fā)送短信驗(yàn)證碼完成注冊功能
  • Android發(fā)送短信功能代碼
  • Android Mms之:短信發(fā)送流程(圖文詳解)
  • android中可以通過兩種方式調(diào)用接口發(fā)送短信
  • WPF MVVM制作發(fā)送短信小按鈕

標(biāo)簽:新疆 長治 上海 沈陽 樂山 河南 滄州 紅河

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《利用VBS發(fā)送短信的實(shí)現(xiàn)代碼(通過飛信)》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    特克斯县| 河曲县| 防城港市| 定西市| 澜沧| 威信县| 广元市| 项城市| 达拉特旗| 墨竹工卡县| 富蕴县| 蕉岭县| 宝清县| 津市市| 思茅市| 彰武县| 临武县| 内乡县| 卓资县| 锡林郭勒盟| 大理市| 永仁县| 综艺| 杭锦后旗| 宁海县| 吉水县| 常德市| 义乌市| 鲜城| 镇原县| 凌云县| 镇平县| 东台市| 盐池县| 克山县| 呼和浩特市| 柏乡县| 田东县| 嫩江县| 翁源县| 德格县|