Search code examples
phptwiliophone-numberphone-calltwilio-api

Show different number in twilio call REST API creating calls


Imagine that I'm creating a new call with REST API and set the parameters like this:

$client->account->calls->create("+15017250604", "+14155551212", $urlCallback);

When the phone rings, I don't wanna show the +15017250604 as the caller, but I wanna show a different number. How can I do that?


Solution

  • Check out the FAQ to add a verified outgoing caller id.

    To use the REST API, POST your phone number to the Outgoing Caller IDs list resource.

    Here's an example to add a new Outgoing Caller ID in PHP:

    <?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 = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    $token = "your_auth_token";
    $client = new Services_Twilio($sid, $token);
    
    $caller_id = $client->account->outgoing_caller_ids->create("+14158675309", array(
            "FriendlyName" => "My Home Phone Number"
        ));
    echo $caller_id->validation_code;