Use VBS to send SMS implementation code (by flying a letter) _vbs

Source: Internet
Author: User
Tags http post php class php and sendmsg
Just look at the title has been very good, heard that you can use PHP to send text messages (fly a letter), but also used the Python implementation of the pyfetion sent a message (fly a letter). I have also seen the corresponding PHP and Python source code, to achieve a more complex, can I use VBS to achieve?

See the code more feel, unexpectedly is the use of 10086.cn (mobile official website) above the interface to achieve, flying letter official has already announced the Flying letter interface? If not, could it be the interface that the author of the code found himself? That's too powerful! Google a moment before found, oh, are not, but WAP flying. The people who live in the Stone Age, like me, who are still using the 2005 production phone to send text messages, of course, do not know the existence of WAP flying letters. I don't even have a short message, let alone fly a letter, I have not remember the last time I landed a letter.
Copy Code code as follows:

m = "xxxyyyyzzzz" ' Mobile number
pass = "12345678" ' Login password
msg = "Hello World" ' flying letter Content
Const online = 1 ' on-line
Const busy = 2 ' busy
Const away = 3 ' leave
Const hidden = 4 ' stealth
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 ' stealth landing
WML = Http.responsetext
If InStr (WML, "Password input error") Then
WScript.Echo "Sorry, password input error, please re-enter!"
Wscript.Quit ' Login failed, exit program
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 ' text messages to your cell phone
WML = Http.responsetext
If InStr (WML, "send successfully") Then WScript.Echo "Send Success"
Http.open "Get", "http://f.10086.cn/im/index/logoutsubmit.action", False
Http.send ' Logout Login

Here is just an example, as to how to send text messages to others and fly a letter, their own pondering it. Originally wanted to write a vbsfetion like pyfetion, but think of no significance, so as to directly install a fly-letter PC client, so do not toss, like tossing students can continue.
The above program can be easily rewritten in other languages, C, C + +, C #, Java, JavaScript, Python, Perl, Ruby, Lua, PHP ... You can do a lot of interesting things with this interface, don't you?

VBS SMS Send Class (Vbsfetion)

Originally wanted to send a message yesterday "with a VBS (fly)" in the VBS program rewritten into PHP, but in order not to repeat the wheel, Google a bit beforehand, found that someone has been realized, see the PHP letter sent class (Phpfetion) v1.2 released. Well, now that someone has encapsulated it into a PHP class, I'm going to encapsulate a VBS class.
Copy Code code as follows:

Class vbsfetion
Private [$mobile], [$password], HTTP
' Author:demon
' website:http://demon.tw
' DATE:2011/6/11
' Initialization event
Private Sub Class_Initialize
Set http = CreateObject ("Msxml2.xmlhttp")
End Sub
' End Event
Private Sub Class_Terminate
Call Logout ()
Set http = Nothing
End Sub
' Initialization function
' Mobile phone number
' Password login password
Public Function Init (mobile, password)
[$mobile] = Mobile
[$password] = password
str = Login ()
If InStr (str, "Password input error") Then
Init = False
Else
Init = True
End If
End Function
' Send a letter
' Mobile phone number
' Message Send content
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
' Send SMS
' Mobile phone number
' Message Send content
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
' Landing
Private Function Login ()
url = "/im/login/inputpasssubmit1.action"
data = "m=" & [$mobile] & "&pass=" & [$password] & "&loginstatus=4"
Login = Post (URL, data)
End Function
' Log Out
Private Function Logout ()
url = "/im/index/logoutsubmit.action"
Logout = Post (URL, "")
End Function
' Send yourself a letter
Private Function tomyself (message)
url = "/im/user/sendmsgtomyselfs.action"
message = "msg=" & Message
tomyself = Post (URL, message)
End Function
' Send a letter to a friend (SMS)
' UID Letter Letter Id
' Message letter (SMS) content
' Isshort True for SMS, False for flying letters
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
' Get the Flying letter Id
' Mobile phone number
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
' Send HTTP POST request
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
Sample programs:
' Initial object
Set fetion = New vbsfetion
' Landing a flying letter
If fetion. Init ("11122223333", "123456") Then
' Send a letter
Fetion. Sendmsg "44455556666", "Hello World"
' Send SMS
Fetion. Sendshortmsg "77788889999", "Hello World"
End If

Source: http://demon.tw/my-work/vbsfetion.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.