File tree Expand file tree Collapse file tree 14 files changed +89
-95
lines changed
play-audio-stream-in-to-call
transfer-a-call-with-ncco Expand file tree Collapse file tree 14 files changed +89
-95
lines changed Original file line number Diff line number Diff line change 44
55// Instruct Nexmo to add this call to a conference
66// Start with an optional announcement using the `talk` action
7- $ ncco = [
8- [
9- ' action ' => ' talk ' ,
10- ' text ' => ' Welcome to the amazing Nexmo conference call '
11- ],
12- [
13- ' action ' => ' conversation ' ,
14- ' name ' => 'amazing-conference-call '
15- ]
16- ] ;
7+
8+ $ ncco = new \ Nexmo \ Voice \ NCCO \ NCCO ();
9+ $ ncco
10+ -> addAction (
11+ new \ Nexmo \ Voice \ NCCO \ Action \ Talk ( ' Welcome to the amazing Nexmo conference call ' )
12+ )
13+ -> addAction (
14+ new \ Nexmo \ Voice \ NCCO \ Action \ Conversation ( 'amazing-conference-call ' )
15+ )
16+ ;
1717
1818header ('Content-Type: application/json ' );
1919$ json = json_encode ($ ncco );
Original file line number Diff line number Diff line change 1- <?php
1+ <?php
2+
23require_once __DIR__ . '/../config.php ' ;
34require_once __DIR__ . '/../vendor/autoload.php ' ;
45
56// Retrive the inbound call details
67$ from = $ _GET ['from ' ];
78$ to = $ _GET ['to ' ];
89
9- // Create the `connect` NCCO
10- $ ncco = [
11- [
12- 'action ' => 'connect ' ,
13- 'from ' => $ from ,
14- 'endpoint ' => [
15- [
16- 'type ' => 'phone ' ,
17- 'number ' => NEXMO_TO_NUMBER
18- ]
19- ]
20- ]
21- ];
10+ $ ncco = new \Nexmo \Voice \NCCO \NCCO ();
11+ $ ncco ->addAction (
12+ new \Nexmo \Voice \NCCO \Action \Connect (
13+ new \Nexmo \Voice \Endpoint \Phone (NEXMO_TO_NUMBER )
14+ )
15+ );
2216
2317header ('Content-Type: application/json ' );
2418$ json = json_encode ($ ncco );
Original file line number Diff line number Diff line change 55$ keypair = new \Nexmo \Client \Credentials \Keypair (file_get_contents (NEXMO_APPLICATION_PRIVATE_KEY_PATH ), NEXMO_APPLICATION_ID );
66$ client = new \Nexmo \Client ($ keypair );
77
8- $ client ->calls [ UUID ]-> put ( new \ Nexmo \ Call \ Earmuff () );
8+ $ client ->voice ()-> earmuffCall ( UUID );
99sleep (3 );
10- $ client ->calls [ UUID ]-> put ( new \ Nexmo \ Call \ Unearmuff () );
10+ $ client ->voice ()-> unearmuffCall ( UUID );
Original file line number Diff line number Diff line change 11<?php
2+
3+ use Nexmo \Voice \NCCO \NCCO ;
4+
25require_once __DIR__ . '/../../config.php ' ;
36require_once __DIR__ . '/../../vendor/autoload.php ' ;
47
811);
912$ client = new \Nexmo \Client ($ keypair );
1013
11- $ call = $ client ->calls ()->create ([
12- 'to ' => [[
13- 'type ' => 'phone ' ,
14- 'number ' => TO_NUMBER
15- ]],
16- 'from ' => [
17- 'type ' => 'phone ' ,
18- 'number ' => NEXMO_NUMBER
19- ],
20- 'ncco ' => [
21- [
22- 'action ' => 'talk ' ,
23- 'text ' => 'This is a text to speech call from Nexmo '
24- ]
25- ]
26- ]);
14+ $ outboundCall = new \Nexmo \Voice \OutboundCall (
15+ new \Nexmo \Voice \Endpoint \Phone (TO_NUMBER ),
16+ new \Nexmo \Voice \Endpoint \Phone (NEXMO_NUMBER )
17+ );
18+ $ ncco = new NCCO ();
19+ $ ncco ->addAction (new \Nexmo \Voice \NCCO \Action \Talk ('This is a text to speech call from Nexmo ' ));
20+ $ outboundCall ->setNCCO ($ ncco );
21+
22+ $ response = $ client ->voice ()->createOutboundCall ($ outboundCall );
2723
28- print_r ( $ call );
24+ var_dump ( $ response );
Original file line number Diff line number Diff line change 55$ keypair = new \Nexmo \Client \Credentials \Keypair (file_get_contents (NEXMO_APPLICATION_PRIVATE_KEY_PATH ), NEXMO_APPLICATION_ID );
66$ client = new \Nexmo \Client ($ keypair );
77
8- $ client ->calls [ UUID ]-> put ( new \ Nexmo \ Call \ Mute () );
8+ $ client ->voice ()-> muteCall ( UUID );
99sleep (3 );
10- $ client ->calls [ UUID ]-> put ( new \ Nexmo \ Call \ Unmute () );
10+ $ client ->voice ()-> unmuteCall ( UUID );
Original file line number Diff line number Diff line change 55$ keypair = new \Nexmo \Client \Credentials \Keypair (file_get_contents (NEXMO_APPLICATION_PRIVATE_KEY_PATH ), NEXMO_APPLICATION_ID );
66$ client = new \Nexmo \Client ($ keypair );
77
8- $ stream = $ client ->calls [UUID ]->stream ();
9- $ stream ->setUrl ('https://nexmo-community.github.io/ncco-examples/assets/voice_api_audio_streaming.mp3 ' );
10- $ stream ->put ();
8+ $ client ->voice ()->streamAudio (UUID , 'https://nexmo-community.github.io/ncco-examples/assets/voice_api_audio_streaming.mp3 ' );
Original file line number Diff line number Diff line change 55$ keypair = new \Nexmo \Client \Credentials \Keypair (file_get_contents (NEXMO_APPLICATION_PRIVATE_KEY_PATH ), NEXMO_APPLICATION_ID );
66$ client = new \Nexmo \Client ($ keypair );
77
8- $ dtmf = $ client ->calls [UUID ]->dtmf ();
9- $ dtmf ->setDigits ('2468# ' );
10- $ dtmf ->put ();
8+ $ client ->voice ()->playDTMF (UUID , '2468# ' );
Original file line number Diff line number Diff line change 55$ keypair = new \Nexmo \Client \Credentials \Keypair (file_get_contents (NEXMO_APPLICATION_PRIVATE_KEY_PATH ), NEXMO_APPLICATION_ID );
66$ client = new \Nexmo \Client ($ keypair );
77
8- $ talk = $ client ->calls [ UUID ]-> talk ();
9- $ talk -> setText ( TEXT );
10- $ talk -> setVoiceName ( ' Kimberly ' );
11- $ talk -> put ( );
8+ $ client ->voice ()-> playTTS (
9+ UUID ,
10+ new \ Nexmo \ Voice \ NCCO \ Action \ Talk ( TEXT )
11+ );
Original file line number Diff line number Diff line change 55$ keypair = new \Nexmo \Client \Credentials \Keypair (file_get_contents (NEXMO_APPLICATION_PRIVATE_KEY_PATH ), NEXMO_APPLICATION_ID );
66$ client = new \Nexmo \Client ($ keypair );
77
8- $ call = $ client ->calls ()->get (NEXMO_CALL_UUID );
9- echo json_encode ($ call). PHP_EOL ;
8+ $ call = $ client ->voice ()->get (NEXMO_CALL_UUID );
9+ echo json_encode ($ call-> toArray ()) ;
Original file line number Diff line number Diff line change 1- <?php
1+ <?php
22require_once __DIR__ . '/../../config.php ' ;
33require_once __DIR__ . '/../../vendor/autoload.php ' ;
44
55$ keypair = new \Nexmo \Client \Credentials \Keypair (file_get_contents (NEXMO_APPLICATION_PRIVATE_KEY_PATH ), NEXMO_APPLICATION_ID );
66$ client = new \Nexmo \Client ($ keypair );
77
8- $ filter = new \Nexmo \Call \Filter ();
9- $ filter ->setStart (new DateTime ('- 1 day ' ));
10- $ filter ->setEnd (new DateTime );
8+ $ filter = new \Nexmo \Voice \Filter \ VoiceFilter ();
9+ $ filter ->setDateStart (new DateTime ('-1 Day ' ));
10+ $ filter ->setDateEnd (new DateTime () );
1111
12- foreach ($ client ->calls ($ filter ) as $ call ){
13- echo json_encode ($ call ).PHP_EOL ;
12+ /** @var \Nexmo\Voice\Call $call */
13+ foreach ($ client ->voice ()->search ($ filter ) as $ call ) {
14+ echo json_encode ($ call ->toArray ()) . PHP_EOL ;
1415}
You can’t perform that action at this time.
0 commit comments