【问题标题】:How Do I Change Properties of an Existing Twilio Number?如何更改现有 Twilio 号码的属性?
【发布时间】:2013-12-23 09:05:49
【问题描述】:

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

【问题讨论】:

  • 只需在数组中更改它们
  • 你的意思是我只是用现有的电话号码再次调用create()函数?
  • 一开始我误解了你的问题,看看我贴的答案

标签: php api twilio


【解决方案1】:

更彻底地挖掘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)。

【讨论】:

  • 谢谢。这是有道理的。
猜你喜欢
  • 1970-01-01
  • 2021-01-23
  • 1970-01-01
  • 1970-01-01
  • 2021-05-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-02-25
相关资源
最近更新 更多