GEORGE SCOTT 619-792-7153
  • HOME
  • Adwords Q&A
  • Work Diary
    • 2020-21 Work
    • 2018-19 Work
    • 2016-17 Work
    • 2013-14 Work
  • WEBSITES
  • HUMOR

Get call recording from Twilio API in Asp Classic

8/3/2018

0 Comments

 
​
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

    Archives

    October 2019
    July 2019
    May 2019
    April 2019
    November 2018
    August 2018
    June 2018

San Diego Easy Traffic School | San Diego Small Business Insurance | Traffic School Online | Finish Traffic School Today | Los Angeles Traffic School
  • HOME
  • Adwords Q&A
  • Work Diary
    • 2020-21 Work
    • 2018-19 Work
    • 2016-17 Work
    • 2013-14 Work
  • WEBSITES
  • HUMOR