我使用的是www.txt2day.com API,但今天发现它们似乎不再营业。通过Google搜索,我发现https://www.twilio.com/sms,看起来还可以,但是想知道那里是否还有免费服务。无论如何,我确实在Twilio上进行了注册,但是代码示例不包含ASP Classic的任何内容,也不包含如何使用XMLHTTP对象调用API的内容。
我能够联系Twilio,他们将我引导到他们博客区域下的页面,其中包含示例VB脚本代码。如下。希望这将对其他希望这样做的人有所帮助:
<%
' Replace with your account's settings available in the Dashboard:
accountSID = "ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
authToken = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
' Setup the URL:
baseUrl = "https://api.twilio.com"
smsUrl = baseUrl & "/2008-08-01/Accounts/" & accountSid & "/SMS/Messages"
' Ssetup the request and authorization:
Set objHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
objHTTP.Open "POST", smsUrl, False, accountSid, authToken
objHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
' Message parameters:
From = "your-number-here" ' The number to send the message from
Recipient = "recipient-number-here" ' The number to send the message to
Body = "Sending SMS is easy with Twilio!" ' Message contents
postData = "From =" & Server.URLEncode(from)
postData = postData & "&To =" & Server.URLEncode(Recipient)
postData = postData & "&Body =" & Server.URLEncode(Body)
' Send the POST data:
objHTTP.send postData
' Optionally write out the response if you need to check if it worked:
' Response.Write http.responseText
' Clean up:
Set objHTTP = Nothing
%>