1
votes

I have implemented twilio client calling future using PHP. But sometimes the call is getting disconnected after ringing. When I look into the error log in twilio I can see the message 'You attempted to initiate an outbound phone call to a phone number that is not enabled on your account.'. I am calling from browser to browser and browser to mobile app, so why this message is shown ?.

I am not sure whether this is an issue in caller side or the receiver side.

Twiml code For eg : $to = 'CLIENT3150'

function get_voice_response($to,$from,$name,$image, $group) {
     $response = new VoiceResponse();

     if (!empty($to) && strlen($to) > 0) {
        $number = htmlspecialchars($to);
        $dial = $response->dial('', ['callerId' => $from]);
    
        // wrap the phone number or client name in the appropriate TwiML verb
        // by checking if the number given has only digits and format symbols
        if (preg_match("/^[\d\+\-\(\) ]+$/", $number)) {
           $dial->number($number);
        } else {
           $client = $dial->client($number);
           $client->parameter(['name' => 'FirstName', 'value' => $name]);
           $client->parameter(['name' => 'Image', 'value' => $image]);
           $client->parameter(['name' => 'Group', 'value' => $group]);
        }
     } else {
       $response->say("Thanks for calling!");
     }
     return (string)$response;
 }

Thank you

1
Both numbers are your twilio numbers? - Sergio Tulentsev
I am not calling to a phone number. I am calling from browser to browser and browser to mobile app - skm
The question says you are not calling from browser to browser. - Sergio Tulentsev
Sorry edited now - skm
Can you share the code you are using in your TwiML app to place the outbound call? - philnash

1 Answers

0
votes

Twilio developer evangelist here.

It looks like you are making a call to another client and trying to pass parameters along with the call. When you do this, you need to pass the client name as an <Identity> element within the <Client>, along with the <Parameter> elements.

In PHP this looks like:

$client = $dial->client();
$client->identity($number);
$client->parameter(['name' => 'FirstName', 'value' => $name]);
$client->parameter(['name' => 'Image', 'value' => $image]);
$client->parameter(['name' => 'Group', 'value' => $group]);

Let me know if that helps at all.