通常,当我运行经典ASP脚本拨打电话时,对于200次通话,加载页面大约需要190秒。如何对Twilio进行异步调用,以便我的页面加载更快,而不是等待每次调用Twilio的响应?
我尝试添加CallBackStatus网址,但是,它没有帮助。这是我的代码:
sub CallANumberSpeakAMessage(fromnumber,tonumber,url)
if isnull(fromnumber) or isnull(tonumber) then exit sub
if len(tonumber) < 10 then exit sub
dim baseurl
dim smsurl
dim from
dim recipient
dim body
dim postdata
dim displayreturn
baseUrl = "https://api.twilio.com"
baseUrl = baseUrl & "/2010-04-01/Accounts/" & authSID & "/Calls"
'Debug
'response.write "BaseURL:" & baseUrl & "<br><br>"
'setup the request and authorization
Set http = Server.CreateObject("MSXML2.ServerXMLHTTP")
http.open "POST", baseUrl, False, authSID, authToken
http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
mFromPhone = fromnumber ' the number to call from
mToPhone = tonumber ' the number to dial
url = Url ' URL handler for the call, should return TwiML
callBackUrl = "http://www.abcserver.com/status_callback.asp"
postData = "From=" & Server.URLEncode(mFromPhone)
postData = postData & "&To=" & Server.URLEncode(mToPhone)
postData = postData & "&Url=" & Server.URLEncode(url)
postData = postData & "&Method=GET"
postData = postData & "&StatusCallback=" & Server.URLEncode(callBackUrl)
postData = postData & "&IfMachine=Continue"
http.send postData
Set http = Nothing
end sub
我已经尝试过改变这个&#34; http.open&#34; POST&#34;,baseUrl,False,authSID,authToken&#34; to&#34; http.open&#34; POST&#34;,baseUrl,True,authSID,authToken&#34;。当ServerXMLHTTP对象进行异步调用时,页面加载速度很快,但是,它并没有真正调用Twilio,也没有真正发生。
非常感谢任何帮助。