File tree Expand file tree Collapse file tree 2 files changed +36
-2
lines changed
voice/transfer-a-call-with-ncco Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Original file line number Diff line number Diff line change 11NEXMO_API_KEY=
22NEXMO_API_SECRET=
3- APPLICATION_ID =
4- PRIVATE_KEY =
3+ NEXMO_APPLICATION_ID =
4+ NEXMO_APPLICATION_PRIVATE_KEY_PATH =
55FROM=
66NEXMO_TO_NUMBER=
77RECIPIENT_NUMBER=
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ require_once __DIR__ . '/../../config.php ' ;
4+ require_once __DIR__ . '/../../vendor/autoload.php ' ;
5+
6+ $ keypair = new \Nexmo \Client \Credentials \Keypair (file_get_contents (NEXMO_APPLICATION_PRIVATE_KEY_PATH ), NEXMO_APPLICATION_ID );
7+ $ client = new \Nexmo \Client ($ keypair );
8+
9+ if (count ($ argv ) != 2 ) {
10+ error_log ("You must supply a UUID of currently connected call to update " );
11+ exit (1 );
12+ }
13+
14+ $ uuid = $ argv [1 ];
15+
16+ try {
17+ $ client ->calls [$ uuid ]->put ([
18+ 'action ' => 'transfer ' ,
19+ 'destination ' => [
20+ 'type ' => 'ncco ' ,
21+ 'ncco ' => [[
22+ 'action ' => 'talk ' ,
23+ 'text ' => 'This call was transferred '
24+ ]],
25+ ]
26+ ]);
27+ } catch (\Nexmo \Client \Exception \Request $ e ) {
28+ error_log ("Client error: " . $ e ->getMessage ());
29+ exit (1 );
30+ } catch (\Nexmo \Client \Exception \Server $ e ) {
31+ error_log ("Server error: " . $ e ->getMessage ());
32+ exit (1 );
33+ }
34+
You can’t perform that action at this time.
0 commit comments