当我通过twilio购买电话号码时,我可以为这样的电话号码设置各种属性:
$sid = 'AC...';
$token = '8...';
$number = '+12345678901';
$client = new Services_Twilio($sid, $token);
$response = $client->account->incoming_phone_numbers->create(
array(
"PhoneNumber" => $number,
"FriendlyName" => "My Company Line",
"VoiceUrl" => "http://testsite.com-callback-url-1.xml",
"VoiceMethod" => "GET"
)
);
如何修改现有的号码详情?
例如,我想将数字细节更改为其他内容。说FriendlyName
到My Personal Line
,Voice_url
到http://testsite.com-callback-url-2.xml
和VoiceMethod
到POST
。
答案 0 :(得分:2)
更深入地了解Twilio API description。
您应该使用另一个API调用来更新信息。以下是更新的示例代码:
$number = $client->account->incoming_phone_numbers->get("PN2a0747eba6abf96b7e3c3ff0b4530f6e");
$number->update(array(
"FriendlyName " => "My Personal Line",
"Voice_url" => "http://testsite.com-callback-url-2.xml",
"VoiceMethod " => "POST"
));
如果我理解正确$client->account->incoming_phone_numbers->create
已经返回了电话号码对象,那么您只需将代码中的$response
重命名为$number
并调用update
方法(不致电client->account->incoming_phone_numbers->get
)。