简体   繁体   English

Web 浏览器语音通话使用 Nexmo PHP Laravel

[英]Web browser audio call using Nexmo PHP Laravel

I want to make a call from a web application(PHP/Laravel) to any mobile number from (purchased Nexmo Number).我想从 web 应用程序(PHP/Laravel)向(购买的 Nexmo 号码)的任何手机号码拨打电话。 It's like a two-way communications call.这就像一个双向通信呼叫。

The scenario assumes in the web application(PHP/Laravel) page display the call driver options placed the call icon.该场景假设在 web 应用程序(PHP/Laravel)页面显示调用驱动程序选项放置调用图标。 Once customers click the call icon then call to driver number from (purchased Nexmo Number).一旦客户单击呼叫图标,然后从(购买的 Nexmo 号码)呼叫驱动程序号码。

I have used this API to create a call.我已经使用这个 API 来创建调用。

    $ncco = [
      [
        'action' => 'talk',
        'voiceName' => 'Joey',
        'text' => 'This is a text-to-speech test message.'
      ]
    ];

    $call = new \Nexmo\Call\Call();
    $call->setTo('XXXXXXXXXXXX')
      ->setFrom('XXXXXXXXXXXX')
      ->setNcco($ncco);

    $response = $client->calls()->create($call);
    echo $response->getId();

The Nexmo Voice API here one-way communication only working fine for me. Nexmo Voice API 这里的单向通信只对我有用。 For example, text to speech call works for me, the above voice API code run the call automatically reached to destination number from (purchased Nexmo Number).例如,文本到语音呼叫对我有用,上面的语音 API 代码运行呼叫自动到达目的地号码(购买的 Nexmo 号码)。

Is anybody has done this scenario?有人做过这个场景吗? when you click on the phone icon it will call customers + you can talk with customer using a web portal?当您单击电话图标时,它将呼叫客户 + 您可以使用 web 门户与客户交谈?

There are two ways to go about this. go 关于这个有两种方法。

Call Bridging呼叫桥接

You can bridge two numbers together by having the system call you, and if you answer then call someone else to bridge them in. This can all be done on the server side much like what you have above, the NCCO just changes slightly.您可以通过让系统呼叫您来将两个号码桥接在一起,如果您接听,则呼叫其他人将它们桥接。这一切都可以在服务器端完成,就像您在上面所做的一样,NCCO 只是略有变化。

$ncco = [
    [
        'action' => 'connect',
        'endpoint' => [
            [
                'type' => 'phone',
                'number' => DRIVER_NUMBER
            ]
        ]
    ]
];

$call = new \Nexmo\Call\Call();
$call->setTo(CUSTOMER_NUMBER)
  ->setFrom(VONAGE_NUMBER)
  ->setNcco($ncco);

$response = $client->calls()->create($call);
echo $response->getId();

The only real problem with this is the user experience.唯一真正的问题是用户体验。 The user probably expects the call work like a real phone call (click the button, hear ringing, hope the driver connects).用户可能希望呼叫像真正的电话一样工作(单击按钮,听到振铃,希望驱动程序连接)。 You would need to add some additional NCCO options like streaming a ring tone, checking to see if the other person declines the call or never answers and responding appropriately, etc, but it can be done by pushing some NCCOs around and watching the voice events.您需要添加一些额外的 NCCO 选项,例如流式传输铃声、检查对方是否拒绝呼叫或从未接听并适当响应等,但可以通过推动一些 NCCO 并观看语音事件来完成。

In Browser/In App在浏览器中/在应用程序中

The other option is our Client SDK , which is available for front-end JavaScript, iOS, and Android.另一个选项是我们的客户端 SDK ,它适用于前端 JavaScript、iOS 和 ZE84ZDB60B9398784D3E9Z This can be used to place a call from a browser or app, and do functionally the same but from within a dedicated interface.这可用于从浏览器或应用程序发出呼叫,并且在功能上相同,但在专用界面内。 A short tutorial can be found at https://developer.nexmo.com/client-sdk/tutorials/app-to-phone/introduction/javascript .可以在https://developer.nexmo.com/client-sdk/tutorials/app-to-phone/introduction/javascript找到一个简短的教程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM