Last active
December 30, 2015 21:39
-
-
Save sammachin/7888612 to your computer and use it in GitHub Desktop.
Selecting and then adding a specific number to a Tropo application
This file contains 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
(Examples written using httpie as a command line tool) | |
username and password are the values you use on the tropo web portal | |
Request a selection of avalible numbers for a given city prefix in this case 415 (San Francisco) | |
http --auth username:password GET http://api.tropo.com/addresses available==1 prefix==1415 | |
This will return a JSON object as below that contains a selection of avalible numbers | |
HTTP/1.1 200 OK | |
Connection: close | |
Content-Type: application/json | |
Date: Tue, 10 Dec 2013 10:16:06 GMT | |
Server: Apache-Coyote/1.1 | |
X-Api-Version: 1 | |
X-Powered-By: Servlet 2.4; JBoss-4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)/JBossWeb-2.0 | |
[ | |
{ | |
"city": "San Francisco", | |
"country": "United States", | |
"displayNumber": "+1 415-326-6708", | |
"href": "http://api.tropo.com/v1/addresses/number/+14153266708", | |
"number": "+14153266708", | |
"prefix": "1415", | |
"smsEnabled": true, | |
"state": "CA", | |
"type": "number" | |
}, | |
{ | |
"city": "San Francisco", | |
"country": "United States", | |
"displayNumber": "+1 415-523-0483", | |
"href": "http://api.tropo.com/v1/addresses/number/+14155230483", | |
"number": "+14155230483", | |
"prefix": "1415", | |
"smsEnabled": true, | |
"state": "CA", | |
"type": "number" | |
}, | |
{ | |
"city": "San Francisco", | |
"country": "United States", | |
"displayNumber": "+1 415-523-0555", | |
"href": "http://api.tropo.com/v1/addresses/number/+14155230555", | |
"number": "+14155230555", | |
"prefix": "1415", | |
"smsEnabled": true, | |
"state": "CA", | |
"type": "number" | |
}, | |
{ | |
"city": "San Francisco", | |
"country": "United States", | |
"displayNumber": "+1 415-429-0056", | |
"href": "http://api.tropo.com/v1/addresses/number/+14154290056", | |
"number": "+14154290056", | |
"prefix": "1415", | |
"smsEnabled": true, | |
"state": "CA", | |
"type": "number" | |
}, | |
{ | |
"city": "Point Reyes", | |
"country": "United States", | |
"displayNumber": "+1 415-938-8062", | |
"href": "http://api.tropo.com/v1/addresses/number/+14159388062", | |
"number": "+14159388062", | |
"prefix": "1415", | |
"smsEnabled": true, | |
"state": "CA", | |
"type": "number" | |
}, | |
{ | |
"city": "Point Reyes", | |
"country": "United States", | |
"displayNumber": "+1 415-938-8063", | |
"href": "http://api.tropo.com/v1/addresses/number/+14159388063", | |
"number": "+14159388063", | |
"prefix": "1415", | |
"smsEnabled": true, | |
"state": "CA", | |
"type": "number" | |
} | |
] | |
(Note: I've removed a few numbers from the response to keep this shorter you should get a larger selection back for most cities) | |
Select the number that you want to purchaase then add it to your app replaceing 123456 with your app id number and prefix with the number you want to purchase from the list above, remember to strip any whitespace and other charactoers from the number, in this example I have added the number 14159388062 | |
http --auth user:password POST https://api.tropo.com/v1/applications/123456/addresses type=number prefix="14159388062" | |
At this point the number has been added to your app :) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would add -v to this command line so that you see any error response headers.