简体   繁体   English

Twilio 可编程语音通话安卓

[英]Twilio programmable voice call android

I just want to integrate twilio programmable voice on my project(android + PHP) so when i dial a VOIP call using android app than the person who will receive call will hear twiml programmable message on call.我只想在我的项目(android + PHP)中集成 twilio 可编程语音,所以当我使用 android 应用程序拨打 VOIP 电话时,接听电话的人将听到 twiml 可编程消息随叫随到。

I have tried a lot and VOIP call is working fine but i want to add a programmable message when receiver will accept the call.我已经尝试了很多并且 VOIP 通话工作正常,但我想在接收方接受通话时添加一个可编程消息。

$callerNumber = '+123456789';

$response = new Twilio\Twiml();

if (!isset($to) || empty($to)) {
  $response->say('Congratulations! You have just made your first call! Good bye.');
} else if (is_numeric($to)) {


  $dial = $response->dial(
    array(
      'callerId' => $callerNumber,
    ));

  $dial->number($to);
} else {
  $dial = $response->dial(
    array(
       'callerId' => $callerId,

    ));
  $dial->client($to);


}
print $response;

I have used above code in the back-end and my VOIP call is working fine but i want to add a programmable message when receiver accept the call我在后端使用了上面的代码,我的 VOIP 呼叫工作正常,但我想在接收方接受呼叫时添加可编程消息

Twilio developer evangelist here. Twilio 开发人员布道者在这里。

In order to add a message to the receiver's call before they are connected, known as a call whisper you need to add a url attribute to your <Number> TwiML .为了在连接之前向接收方的呼叫添加消息,称为呼叫耳语,您需要向<Number> TwiML添加一个url属性

The URL in the attribute will receive a webhook when the person answers the phone.当该人接听电话时,该属性中的 URL 将收到一个 webhook。 Return TwiML to the request and that TwiML will be played to the person on the phone before they are connected.将 TwiML 返回到请求中,并且 TwiML 将在他们连接之前播放给电话上的人。

In your PHP, this looks like:在您的 PHP 中,这看起来像:

  $dial = $response->dial(
    array(
      'callerId' => $callerNumber,
    ));

  $dial->number($to, ['url' => 'https://example.com/whisper'];

Then, for the /whisper endpoint you can return TwiML that reads out a message with <Say> for example:然后,对于/whisper端点,您可以返回使用<Say>读出消息的 TwiML,例如:

$response = new Twilio\Twiml();

$response->say('Congratulations! This is a whisper!');

print $response;

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

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