Reputation: 2816
When I am purchasing a phone number via twilio I can setup various properties for the phone number like this:
$sid = 'AC...';
$token = '8...';
$number = '+12345678901';
$client = new Services_Twilio($sid, $token);
$response = $client->account->incoming_phone_numbers->create(
array(
"PhoneNumber" => $number,
"FriendlyName" => "My Company Line",
"VoiceUrl" => "http://testsite.com-callback-url-1.xml",
"VoiceMethod" => "GET"
)
);
How do I Edit and Existing Number Details?
For example, I want to change the number details to something else. Say FriendlyName
to My Personal Line
, Voice_url
to http://testsite.com-callback-url-2.xml
and VoiceMethod
to POST
.
Upvotes: 1
Views: 281
Reputation: 11061
Dig more thoroughly into the Twilio API description.
You should use another API call for information updating. Here is the sample code for update:
$number = $client->account->incoming_phone_numbers->get("PN2a0747eba6abf96b7e3c3ff0b4530f6e");
$number->update(array(
"FriendlyName " => "My Personal Line",
"Voice_url" => "http://testsite.com-callback-url-2.xml",
"VoiceMethod " => "POST"
));
If I understand correctly $client->account->incoming_phone_numbers->create
already returns you the phone number object, so you just have to rename $response
in your code to $number
and call update
method (without calling client->account->incoming_phone_numbers->get
).
Upvotes: 2