How to transfer phone number from master account to subaccount

半世苍凉 提交于 2021-02-07 02:53:32

问题


I have read the tutorial in twilio but its not quite clear.

Can someone lay down the step by step procedure please?

Here is what I got from twilio:

Exchanging Phone Numbers Between Accounts

You can transfer numbers between subaccounts, and between your master account and any one of your subaccounts. You must use your master account's credentials when making the API request to transfer a phone number.

To transfer a phone number between two accounts that you control, make an HTTP POST request to an IncomingPhoneNumber instance resource URI. In the body of the POST set the parameter 'AccountSid' to the AccountSid of the account you wish to own that number. This will remove the phone number from its original account and make it available under the IncomingPhoneNumbers list resource of the new account while retaining all other properties.

Remember, closing a subaccount as described above will release all of that account's phone numbers, so you might consider transferring all numbers to your master account beforehand if you want to keep them.


回答1:


One line with curl https://curl.haxx.se/.

You will need to know:

  • from the account where the phone number currently is

    SOURCE-ACCOUNT-SID

    PHONE-NUMBER-SID

  • from the account where the phone number will be transfered

    DESTINATION-ACCOUNT-SID

  • from your master Twilio account

    MASTER-ACCOUNT-SID

    MASTER-ACCOUNT-TOKEN

Here is the command:

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"

.

Note: when you replace the values it looks something like this

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




回答2:


Twilio evangelist here.

To transfer a phone number from a master account to a subaccount, you'll make a POST request to the IncomingPhoneNumber resource that you want to transfer, setting the AccountSid of that resource to the Subaccount SID that you want to move the account into. Using the PHP helper it looks like this:

//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"
));

Hope that helps.




回答3:


You can do this easily in 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)

Make sure to install twilio's Python package if you haven't already:

pip install twilio


来源:https://stackoverflow.com/questions/26327200/how-to-transfer-phone-number-from-master-account-to-subaccount

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!