简体   繁体   English

尝试将 nexmo CallerID 添加到 voice_api 脚本

[英]Trying to add nexmo CallerID to voice_api script

I am a beginner with nexmo.我是 nexmo 的初学者。 Using the nexmo voice-api.使用 nexmo 语音 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... nexmo 脚本执行此操作...

1 - $from (nexmo number) calls $to (office phone) 2 - $to picks up and text says connecting call 3 - then dials $connect 1 - $from(nexmo 号码)呼叫 $to(办公室电话) 2 - $to 接听并且文本显示正在连接呼叫 3 - 然后拨打 $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.当前问题:更改现在显示 $from(nexmo 号码)的 CallerID,并将 CallerID 显示为 $to(办公室电话)号码。

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...我希望有一些简单的事情,比如添加一个像下面这样的“CallerID”标签......这样目标电话就会看到来自办公室电话而不是nexmo电话的来电显示......

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.您应该能够将 $from 数字更改为 $to 数字。 the $from parameter can be set to any valid phone number $from 参数可以设置为任何有效的电话号码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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