【问题标题】:Twilio programmable voice call androidTwilio可编程语音通话android
【发布时间】:2019-07-15 09:52:51
【问题描述】:

我只想在我的项目中集成 twilio 可编程语音(android + PHP),所以当我使用 android 应用拨打 VOIP 电话时,接听电话的人会听到 twiml 可编程消息待命。

我已经尝试了很多,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;

我在后端使用了上面的代码,我的 VOIP 通话工作正常,但我想在接收者接受呼叫时添加一条可编程消息

【问题讨论】:

    标签: php android twilio twilio-api twilio-php


    【解决方案1】:

    这里是 Twilio 开发者宣传员。

    为了在连接之前向接收者的呼叫添加消息,称为call whisper,您需要添加url attribute to your <Number> TwiML

    当该人接听电话时,属性中的 URL 将收到一个 webhook。将 TwiML 返回到请求中,然后 TwiML 将在电话上的人连接之前播放给他们。

    在您的 PHP 中,这看起来像:

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

    然后,对于 /whisper 端点,您可以返回 TwiML,它会读出带有 <Say> 的消息,例如:

    $response = new Twilio\Twiml();
    
    $response->say('Congratulations! This is a whisper!');
    
    print $response;
    

    【讨论】:

      猜你喜欢
      • 2021-12-22
      • 1970-01-01
      • 2017-11-14
      • 1970-01-01
      • 1970-01-01
      • 2017-06-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多