获取 Twilio Softphone/Twilio.js 来电/去电的 CallSID [英] Getting CallSID for Twilio Softphone / Twilio.js incoming/outgoing calls

查看:25
本文介绍了获取 Twilio Softphone/Twilio.js 来电/去电的 CallSID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 https://www 创建了一个应用程序.twilio.com/docs/howto/twilio-client-browser-soft-phone 作为模板.我正在尝试记录来电和去电的 CallSid,以便我可以在本地标记呼叫并使用 Callsid 在我的本地数据和 twilio 的呼叫存储之间进行链接.我可以通过以下方式轻松获取来电的 CallSid:

I have created an application using https://www.twilio.com/docs/howto/twilio-client-browser-soft-phone as the template. I am trying to log the CallSid for incoming and outgoing calls so that I can tag calls locally and use the Callsid to link between my local data and twilio's call store. I am able to get the CallSid for incoming calls easily with:

Twilio.Device.incoming(function (conn) {
   if (confirm('Accept incoming call from ' + conn.parameters.From + '?')){
      connection=conn;
      conn.accept();
      callsid = connection.parameters.CallSid;
   }
   else {
      connection=conn;
      conn.reject();
   }
});

但是,我似乎无法从软电话发起的任何拨出电话中获得它.我在这里尝试过:

However, I can't seem to get it from any outgoing call initiated by the softphone. I have tried here:

$("#call").click(function() {
   params = { "tocall" : $('#tocall').val()};
   connection = Twilio.Device.connect(params);
   callsid = connection.parameters.CallSid;
});

这里:

Twilio.Device.connect(function (conn) {
   $('#status').text("Successfully established call");
   toggleCallStatus();
   callsid = connection.parameters.CallSid;
   // And also tried
  callsid = conn.parameters.CallSid;
});

然而,这两者都返回 undefined.我在 https://www.twilio.com/docs/client/connection 上看到CallSid 在页面底部的 Outgoing .parameters 中设置,所以我认为它应该在这些函数调用之一中可用.

However, both of these return undefined. I saw on https://www.twilio.com/docs/client/connection that the CallSid is set in the Outgoing .parameters towards the bottom of the page, so I assume it should be available in one of these function calls.

CallSid 是否可用于客户端发起的呼叫?如果是这样,我在哪里/如何访问它?

Is the CallSid available for calls originated by the client? And if so, where/how do I access it?

推荐答案

好吧,你得到的connection.parameters是空的,你可以通过插拔检查console.dir(连接)

Well, the connection.parameters you are getting is empty and you can check this by plugging console.dir(connection)

然而,原因是:Twilio 不会在 twilio.js V: 1.1 的传出连接上填充参数,仅用于传入连接所以请使用 twilio.js 1.2 使其工作:)

However, the reason is : Twilio does not populate parameters on outgoing connections for twilio.js V: 1.1 only for incoming connection so please use twilio.js 1.2 to make it works :)

这篇关于获取 Twilio Softphone/Twilio.js 来电/去电的 CallSID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆