question

Robert Goth avatar image
Robert Goth asked Robert Goth commented

Set Caller ID with PHP and ring-out

I am trying to call a number using "/restapi/v1.0/account/~/extension/~/ring-out" in php

I have the body set up like this

$body = array(

'from' => array(

'phoneNumber' => $fromNumber

),

'to' => array(

'phoneNumber' => $toNumber

),

'callerId' => array(

'phoneNumber' => $CallerIDPhoneNumber

),

'playPrompt' => false


);


If I make the call and have the $fromNumber and the $CallerIDPhoneNumber number as the same number it works fine but I want the $CallerIDPhoneNumber to always be the main office number regardless of where I am calling from. If I change the $CallerIDPhoneNumber to any other number than the $fromNumber number it does not work. any Ideas what I am doing wrong?

call handling
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image
Phong Vu answered

There is nothing wrong with your code. You said it does not work if you change the caller id number. What happens when it does not work? An error? The caller (from number) does not see the correct caller id, or what?

You can make sure the caller id you are using is valid by calling this endpoint and check if the number has the CallerId feature before using it as a callerId.

$response = $platform->get('/account/~/extension/~/phone-number');

foreach ($response->json()->records as $record){
    print_r ("This phone number ".$record->phoneNumber." has the following features: "."\n");
    foreach ($record->features as $feature)
        print_r (" => ".$feature."\n");
}
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Robert Goth avatar image
Robert Goth answered

The php page will not load/crashes and the call is not placed. The caller ID is valid. Is there a way to see what is making the error. It only happens like I said if the Caller ID number is not the same as the From number.

1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Robert Goth avatar image
Robert Goth answered Robert Goth commented

This works,

$fromNumber ="140xxx01";

$CallerIDPhoneNumber ="140xxx01";

the following occurs

1) call is place 2) the php page loads 3) caller Id on recieving call shows the following number: 140xxx01


and this also works

$fromNumber ="140xxx02";

$CallerIDPhoneNumber ="140xxx02";

1) call is place 2) the php page loads 3) caller Id on recieving call shows the following number: 140xxx02


but this does not

$fromNumber ="140xxx01";

$CallerIDPhoneNumber ="140xxx02";

no call is placed and an error occurs resulting in the php page crashing/not loading:

3 comments
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image Phong Vu ♦♦ commented ·

That is weird and I would say that it's not because of PHP code nor the ring-out API. If this happens on your production account, submit a dev support case so someone can have a look at your account. If this is your sandbox account, provide me with the account main company number.

0 Likes 0 ·
Phong Vu avatar image Phong Vu ♦♦ commented ·

BTW, if 140xxx02 is a direct number or a digital line, it cannot be used as a caller id for a ring out placed by another extension which does not own the 140xxx02 number. In other words, caller id can be only main company number, company numbers and an authenticated extension own numbers.

0 Likes 0 ·
Robert Goth avatar image Robert Goth Phong Vu ♦♦ commented ·

Ok That got me to where I needed. I was using a sandbox account and was trying to use the main number for my actual account as the caller ID. This was causing the fail. If I use the provided number for the sandbox account as the Caller ID number than it works as it should showing the Caller ID as the Temp Sandbox main number I assume once I merge to production account I will be then be able to use the main company number as the Caller ID. Thanks.

0 Likes 0 ·

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys