将ASP Classic与Twilio SMS API结合使用[关闭]

问题描述 投票:-2回答:1
我已经在Twilio注册,但是代码示例不包含ASP Classic的任何内容,也不包含如何使用XMLHTTP对象调用API的任何内容。如何完成?
vbscript asp-classic twilio sms-gateway
1个回答
0
投票
我能够联系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 %>

© www.soinside.com 2019 - 2024. All rights reserved.