我正在尝试使用twilio上的客户端上传并尝试购买twilio号码。
此外,我需要获取动态语音网址,以便动态录制电话会议。
<?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帐户。
答案 0 :(得分: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;