最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

SignalWire Two-Way Call Functionality in ColdFusion: No Audio Issue - Stack Overflow

programmeradmin2浏览0评论

I'm implementing a two-way call functionality in ColdFusion using SignalWire's API, but the call gets triggered twice, and both participants cannot hear any audio.

ColdFusion API Request Code:

<cffunction name="signalWireTwoWayCalling" access="remote" returnformat="json">
    <cfargument name="toNumber" type="string" required="false">

    <cfset var response = {}>

    <!--- SignalWire API credentials --->
    <cfset spaceURL = ";>
    <cfset projectID = "YOUR_PROJECT_ID">
    <cfset authToken = "YOUR_AUTH_TOKEN">
    <cfset fromNumber = "+1**********">

    <cfset arguments.toNumber = "+1*********">

    <!--- Construct the API URL --->
    <cfset apiUrl = spaceURL & "/api/laml/2010-04-01/Accounts/" & projectID & "/Calls.json">

    <!--- Webhook URL for call handling --->
    <cfset callHandlerUrl = ".cfm?toNumber=" & arguments.toNumber>

    <!--- Prepare the request body --->
    <cfset requestBody = {
        "To" = arguments.toNumber,
        "From" = fromNumber,
        "Url" = callHandlerUrl
    }>

    <cfset requestBodyJson = serializeJSON(requestBody)>

    <cfhttp url="#apiUrl#" method="post" result="httpResponse">
        <cfhttpparam type="header" name="Content-Type" value="application/json">
        <cfhttpparam type="header" name="Authorization" value="Basic #toBase64(projectID & ':' & authToken)#">
        <cfhttpparam type="body" value="#requestBodyJson#">
    </cfhttp>

    <cfset responseData = deserializeJSON(httpResponse.FileContent)>
    <cfreturn responseData>
</cffunction>

Call Handling (callHandler.cfm):

<cfprocessingdirective suppresswhitespace="yes">
<cfcontent type="text/xml">
<cfparam name="url.toNumber" default="+16507626368">
<cfoutput><?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Dial>
        <Number>#url.toNumber#</Number>
    </Dial>
</Response>
</cfoutput>
</cfprocessingdirective>

Issue:

  1. Two calls are triggered instead of one.
  2. No audio is transmitted; both participants cannot hear each other.

Things Tried:

  • Verified that the API response is successful.
  • Confirmed that callHandler.cfm returns valid XML.
  • Tested different phone numbers, but the issue persists.

Questions:

  • Am I incorrectly handling the Dial request in callHandler.cfm?
  • Is there something missing in the way I initiate the call via cfhttp?
  • How can I ensure only one call is triggered and that participants can hear each other?

Would appreciate any guidance. Thanks!

发布评论

评论列表(0)

  1. 暂无评论