【问题标题】:How to transfer phone number from master account to subaccount如何将电话号码从主账户转移到子账户
【发布时间】:2014-10-12 16:15:36
【问题描述】:

我已经阅读了 twilio 中的教程,但不是很清楚。

有人能详细说明一下步骤吗?

这是我从 twilio 得到的:

在帐户之间交换电话号码

您可以在子账户之间以及您的主账户和您的任何一个子账户之间转移号码。发出 API 请求以转移电话号码时,您必须使用主帐户的凭据。

要在您控制的两个帐户之间传输电话号码,请向 IncomingPhoneNumber 实例资源 URI 发出 HTTP POST 请求。在 POST 的正文中,将参数“AccountSid”设置为您希望拥有该号码的帐户的 AccountSid。这将从其原始帐户中删除电话号码,并使其在新帐户的 IncomingPhoneNumbers 列表资源下可用,同时保留所有其他属性。

请记住,如上所述关闭子帐户将释放该帐户的所有电话号码,因此如果您想保留这些号码,可以考虑事先将所有号码转移到您的主帐户。

【问题讨论】:

  • 这里是 Twilio 传播者。你用的是什么编程语言?
  • 嗨德文,我正在使用 php

标签: twilio multi-tenant twilio-api


【解决方案1】:

一行用 curl https://curl.haxx.se/.

你需要知道:

  • 来自当前电话号码所在的帐户

    SOURCE-ACCOUNT-SID

    PHONE-NUMBER-SID

  • 从将要转移电话号码的帐户

    DESTINATION-ACCOUNT-SID

  • 来自您的 Twilio 主帐户

    MASTER-ACCOUNT-SID

    MASTER-ACCOUNT-TOKEN

命令如下:

curl -XPOST https://api.twilio.com/2010-04-01/Accounts/SOURCE-ACCOUNT-SID/IncomingPhoneNumbers/PHONE-NUMBER-SID.json -d "AccountSid=DESTINATION-ACCOUNT-SID" -u "MASTER-ACCOUNT-SID:MASTER-ACCOUNT-TOKEN"

.

注意:当您替换值时,它看起来像这样

curl -XPOST https://api.twilio.com/2010-04-01/Accounts/AC0123456789abcdefabcdefabcdefabcd/IncomingPhoneNumbers/PN0123456789abcdefabcdefabcdefabcd.json -d "AccountSid=AC0123456789abcdefabcdefabcdefabcd" -u "AC0123456789abcdefabcdefabcdefabcd:0123456789abcdefabcdefabcdefabcd"

【讨论】:

  • 即使按照 Twilio 网站上的文档(这是不同的!),使用您的示例也能以某种方式工作。谢谢!
【解决方案2】:

Twilio 布道者在这里。

要将电话号码从主帐户转移到子帐户,您需要向要转移的 IncomingPhoneNumber 资源发出 POST 请求,将该资源的 AccountSid 设置为您要移动帐户的子帐户 SID进入。使用 PHP 助手,它看起来像这样:

//Create a new instance of the helper library using master accounts credentials
$client = new Services_Twilio($sid, $token);

// Get the phone number that you want to transfer
$number = $client->account->incoming_phone_numbers->get("PN2a0747eba6abf96b7e3c3ff0b4530f6e");

// update the phone number resources with the account sid of the subaccount
$number->update(array(
    "AccountSid" => "ACecb5a0741d3b8570bcb094ea4dd471d4"
));

希望对您有所帮助。

【讨论】:

    【解决方案3】:

    您可以在 Python 中轻松做到这一点:

    from twilio.rest import TwilioRestClient
    client = TwilioRestClient(MASTER_ACCOUNT_SID, MASTER_AUTH_TOKEN)
    account = client.accounts.get(MASTER_ACCOUNT_SID)
    number = account.incoming_phone_numbers.get(NUMBER_SID)
    number.update(account_sid=SUBACCOUNT_SID)
    

    如果您还没有安装 twilio 的 Python 包,请确保安装:

    pip install twilio
    

    【讨论】:

    • 这个答案现在已经过时了。 from twilio.rest import Client client = Client(MASTER_ACCOUNT_SID, MASTER_AUTH_TOKEN) account = client.accounts.get(MASTER_ACCOUNT_SID) number = account.incoming_phone_numbers.get(NUMBER_SID) number.update(account_sid=SUBACCOUNT_SID) 不过现在似乎可以工作了。跨度>
    猜你喜欢
    • 1970-01-01
    • 2021-10-09
    • 1970-01-01
    • 1970-01-01
    • 2014-12-09
    • 2013-10-22
    • 1970-01-01
    • 1970-01-01
    • 2018-08-06
    相关资源
    最近更新 更多