如何更改现有Twilio编号的属性?

时间:2013-12-23 09:05:49

标签: php api twilio

当我通过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"
    )
);

如何修改现有的号码详情?

例如,我想将数字细节更改为其他内容。说FriendlyNameMy Personal LineVoice_urlhttp://testsite.com-callback-url-2.xmlVoiceMethodPOST

1 个答案:

答案 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)。