简体   繁体   中英

Trying to add nexmo CallerID to voice_api script

I am a beginner with nexmo. Using the nexmo voice-api. I have created a basic script that does the following:

Goal:

$from number (xxx xxx 0000) // nexmo number
$to number  (xxx xxx 1111) //office desk phone
$connect number (xxx xxx 2222) //destination phone

nexmo script does this...

1 - $from (nexmo number) calls $to (office phone) 2 - $to picks up and text says connecting call 3 - then dials $connect

Current Issue: to change the CallerID that is now showing the $from (nexmo number) and have the CallerID show instead as the $to (office phone) number.

I was hoping for something simple like adding a 'CallerID' tag like below... so that the destination call would see the caller id from the OFFICE phone not the nexmo phone...

Is this possible somehow?

    //ORIGINAL SCRIPT
//
$from = 'xxxxxx1111';
$to = 'xxxxxx2222';
$connect = 'xxxxxx3333';require_once "vendor/autoload.php";$keypair = new \Nexmo\Client\Credentials\Keypair(
file_get_contents('private.key'),
'xxxxxx'
);$client = new \Nexmo\Client($keypair);$ncco = [[
'action' => 'talk',
'voiceName' => 'Nicole',
'text' => 'Connecting your call now.'
],[
'action' => 'connect',
'eventUrl' => ["https://example.com/webhooks/update.php"],
'from' => 'xxxxxx1111',

// add somethinhg simple like this?
'??? CallerID ???' => $to, 
//'xxxxxx2222 office phone here'

'endpoint'  =>  [['type' => 'phone','number' => $connect]]
]];try {$call = new \Nexmo\Call\Call();$call->setTo($to)
->setFrom($from)
->setNcco($ncco);$response = $client->calls()->create($call);
echo $response->getId();
}
catch (exception $e) {
    //code to handle the exception    echo 'Message: ' .$e->getMessage();
}
finally {
    //optional code that always runs
}

You should be able to change the $from number to the $to number. the $from parameter can be set to any valid phone number

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM