How can I add/edit phonenumber programmatically using the API in https://www.twilio.com/user/account/voice/phone-numbers.
Twilio developer evangelist here.
To provision a new phone number using the Twilio API is a two step process. First, you need to find an available phone number using the Available Phone Numbers resource. You can do this in PHP like so:
<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library
// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "{{ account_sid }}";
$token = "{{ auth_token }}";
$client = new Services_Twilio($sid, $token);
$numbers = $client->account->available_phone_numbers->getList('US', 'Local');
foreach($numbers->available_phone_numbers as $number) {
echo $number->phone_number;
}
Second, you need to make a request to the Incoming Phone Numbers resource to purchase that number.
// choose $twilio_number from the previous response.
$number = $client->account->incoming_phone_numbers->create(array(
"FriendlyName" => "My Company Line",
"VoiceUrl" => "http://demo.twilio.com/docs/voice.xml",
"PhoneNumber" => $twilio_number
));
You can then update the number using the Incoming Phone Numbers instance resource.
Let me know if that helps at all.