Created
January 27, 2013 08:37
-
-
Save troyscott/4647401 to your computer and use it in GitHub Desktop.
Example of using pycurl to transfer a phone number from a Twilio SubAccount to the Master Account. Couldn't get this to work with the python twilio client.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pycurl | |
| # http://www.twilio.com/docs/api/rest/subaccounts#exchanging-numbers | |
| def reset_demo(phone_sid): | |
| base = "https://api.twilio.com/2010-04-01/Accounts/" | |
| master_sid = "ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" | |
| master_token = "auth token" | |
| subaccount = "ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" | |
| login = "%s:%s" % (master_sid, master_token) | |
| data = "AccountSid=%s" % master_sid | |
| uri = "%s%s/IncomingPhoneNumbers/%s" % (base, subaccount,phone_sid) | |
| c = pycurl.Curl() | |
| c.setopt(c.URL,uri) | |
| c.setopt(c.USERPWD, login) | |
| c.setopt(c.POSTFIELDS, data) | |
| c.setopt(c.VERBOSE, True) | |
| c.perform() | |
| phone_list = ["PNxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", | |
| "PNxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"] | |
| for phone in phone_list: | |
| reset_demo(phone) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment