我只想在我的项目中集成twilio可编程语音( android + PHP),这样当我使用android应用程序拨打VOIP电话时,接到电话的人会在通话中听到两个可编程的信息。
我已经尝试了很多,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呼叫工作正常,但我想在接收方接受呼叫时添加一个可编程的消息
发布于 2019-07-25 13:39:22
Twilio开发者的布道者在这里。
为了在接通之前将消息添加到接收方的呼叫中,您需要添加url attribute to your TwiML,这称为call whisper。
当用户应答电话时,属性中的URL将收到一个webhook。将TwiML返回给请求,在连接之前,将在电话上向该人播放TwiML。
$dial = $response->dial(
array(
'callerId' => $callerNumber,
));
$dial->number($to, ['url' => 'https://example.com/whisper'];然后,对于/whisper端点,您可以返回读出带有的消息的TwiML,例如:
$response = new Twilio\Twiml();
$response->say('Congratulations! This is a whisper!');
print $response;https://stackoverflow.com/questions/57037262
复制相似问题