Implementation Code for sending text messages using VBS (via Apsara)

Source: Internet
Author: User
Tags sendmsg

I think it is awesome to read the title. I have heard that I can use PHP to send text messages (fetion) and Python to implement PyFetion to send text messages (fetion ). I have also read the corresponding PHP and Python source code. The implementation is still complicated. Can I use VBS for implementation?

After seeing the code, I felt that the code was actually implemented using the interface above 10086.cn (Mobile official website). Has the official Apsara stack released the Apsara stack interface? If not, is it an interface discovered by the Code author? That's too powerful! Google once discovered that, oh, none of them, but WAP Feixin. People like me who are still using cell phones that can only send text messages in 2005 and live in the Stone Age do not know the existence of WAP fetion. I seldom send text messages, not to mention Apsara. I don't remember the last time I logged on to Apsara.Copy codeThe Code is as follows: m = "xxxyyyyzzzz" 'mobile phone number
Pass = "12345678" 'Login Password
Msg = "Hello world" 'fetion content
Const online = 1' online
Const busy = 2' busy
Const away = 3' exit
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 Login
Wml = http. responseText
If InStr (wml, "Incorrect password") Then
WScript. Echo "sorry, incorrect password. Please try again! "
WScript. Quit Login Failed, exit the 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 "to send text messages to your mobile phone
Wml = http. responseText
If InStr (wml, "sent successfully") Then WScript. Echo "sent successfully"
Http. open "GET", "http://f.10086.cn/im/index/logoutsubmit.action", False
Http. send 'logout Login

Here is just an example. As for how to send text messages and send emails to others, let's think about it. I originally wanted to write a VbsFetion like PyFetion, but it doesn't make sense to think about it. It's better to directly install an Apsara PC client, so I don't have to worry about it. Students who like it can continue.
The above program can be easily rewritten to other languages, C, C ++, C #, Java, JavaScript, Python, Perl, Ruby, Lua, PHP ...... Using this interface can do a lot of interesting things, isn't it?

Vbs sms sending class (VBSFetion)

I wanted to rewrite the VBS program in yesterday's "using VBS to send text messages (fetion)" into PHP. But to avoid repeating the wheel, I googled it and found someone has implemented it, for details, see PHPFetion v1.2. Well, since someone has encapsulated it into a PHP class, I will encapsulate a VBS class.Copy codeThe Code is 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 no.
'Password Login password
Public Function Init (mobile, password)
[$ Mobile] = mobile
[$ Password] = password
Str = Login ()
If InStr (str, "Incorrect password") Then
Init = False
Else
Init = True
End If
End Function
'Send Apsara
'The mobile phone number of the other party
'Message 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
'The mobile phone number of the other party
''Message 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
'Login
Private Function Login ()
Url = "/im/login/inputpasssubmit1.action"
Data = "m =" & [$ mobile] & "& pass =" & [$ password] & "& loginstatus = 4"
Login = Post (url, data)
End Function
'Logout
Private Function Logout ()
Url = "/im/index/logoutsubmit. action"
Logout = Post (url ,"")
End Function
'Send a mail to yourself
Private Function ToMyself (message)
Url = "/im/user/sendMsgToMyselfs. action"
Message = "msg =" & message
ToMyself = Post (url, message)
End Function
'Send a flying letter (SMS) to a friend)
'Uid Feixin ID
'Message Feixin (SMS) Content
'Isshort True is short message, and False is Feixin
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 Feixin ID
'Mobile phone no.
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 an 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
Example program:
'Initial object
Set fetion = New VBSFetion
'Log On to Apsara Stack
If fetion. Init ("11122223333", "123456") Then
'Send Apsara
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.