使用twilio帐户如何在php中为voiceurl创建动态电话会议

问题描述 投票:0回答:1

我正在尝试使用 twilio 上的客户端上传并尝试购买 twilio 号码。

此外,我需要获取动态语音 URL 才能动态录制电话会议。

<?php


require_once 'vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "*********************";
$token = "*******************";
$client = new Client($sid, $token);


$numbers = $client->availablePhoneNumbers('US')->local->read(
    array("areaCode" => "424")
);

$twilioNumber = $numbers[0]->phoneNumber;

$newNumber = $client->incomingPhoneNumbers->create(
            [
            "voiceUrl" => "host url",
            "voiceMethod" => "GET"
            ]
        );

if ($newNumber) {
            return $twilioNumber;
        } else {
            return 0;
        }

// 在 voiceUrl 参数中,我传递了电话会议连接代码托管链接,但它没有动态更新到 twilio 帐户。

php twilio twilio-api twilio-php
1个回答
0
投票
 You can use like     

 require 'Services/Twilio.php';

 $account_id = ACCOUNT_SID;
 $auth_token = AUTH_TOKEN;

 $number = $_REQUEST['id'];

 $client = new Services_Twilio($account_id, $auth_token);

 try{

 $number= $client->account->incoming_phone_numbers->create(array('PhoneNumber' =>'+'.$number));
$number_sid=$number->sid;
$number1 = $client->account->incoming_phone_numbers->get($number_sid);
$number1->update(array("VoiceUrl" => "http://11.11.1.111/test/twilio_call_response.php","SmsUrl"=>"http://11.11.1.111/test/incomingsms.php","VoiceFallbackUrl"=>"http://11.11.1.111/test/fall_backurl.php"));
$phone_number=str_replace('+','',$numbers);
$allocate='1';

}catch(Exception $e){

 echo $err = "Error purchasing number: {$e->getMessage()}";
}

echo $phone_number;
© www.soinside.com 2019 - 2024. All rights reserved.