With every incoming call, twilio sends a field callSID. Use the callSID field to go back and get the recording of the call. I run this code on the page that displays the call recordings, looping through each phone call that doesn't already have a recording url saved in the database. private sub getRecordingFromTwilio(callSID) baseUrl = "https://api.twilio.com/2010-04-01/Accounts/xxx/Calls/" & callSID & "/Recordings" 'response.write remoteURL Set http = Server.CreateObject("MSXML2.ServerXMLHTTP") http.open "GET", baseUrl, False, "xxxx", "xxxx" http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" http.send displayReturn = http.responSetext 'Get Twilio Response Set fn_xml = Server.CreateObject("msxml2.DOMDocument.6.0") fn_xml.async = False fn_xml.loadxml (displayReturn) on error resume next url = (fn_xml.selectSingleNode("//TwilioResponse/Recordings/Recording/Uri").text) recordingDuration = (fn_xml.selectSingleNode("//TwilioResponse/Recordings/Recording/Duration").text) recordingURL = "https://api.twilio.com" & url & ".mp3" on error goto 0 strSQL = "update log_calls set recordingURL = '" & recordingURL & "',recordingDuration='" & recordingDuration & "' where callSID = '" & callSID & "'" 'response.write strSQL if len(recordingURL) > 10 then rs.Open strSQL, CONNECTIONSTRING, 3, 1 set fn_xml = nothing Set http = Nothing End Sub
0 Comments
|