VBSを利用してメールを送信する実装コード(飛信を通じて)

6315 ワード

タイトルを見ているだけでもすごいと思いますが、PHPでメール(飛信)が送れるとか、Pythonで実現したPyFetionでメール(飛信)が送れるとか聞いたことがあります.私も対応するPHPとPythonのソースコードを見たことがあって、実現するのはやはり比較的に複雑で、まさかVBSで実現することができますか?
コードを見てさらにすごいと思いましたが、10086を使っていました.cn(モバイル公式サイト)上のインタフェースで実現された、飛信公式は飛信インタフェースを発表したのだろうか.そうでなければ、コードの作者自身が発見したインタフェースなのだろうか.それは強すぎる!Googleはすぐに発見して、ああ、すべてではありませんて、WAP飛信です.私のように2005年に生産された電話メールしかできない携帯電話を使って石器時代に生きていた人は、もちろんWAP飛信の存在を知らなかった.私は今メールさえめったに送っていません.ましてや、飛信は言うまでもなく、前回飛信に上陸したのはいつだったか覚えていません.
 
  
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飛信送信類(PHPFition)v 1を参照してください.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 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

ソース:http://demon.tw/my-work/vbsfetion.html