...
Unified API can be tested using the Sandbox numbers. The example below uses the Create Simple PhoneCalls request to make the call.
Code Block | ||
---|---|---|
| ||
<?php // Modify these values with the ones you intend to use define('VN_SERVER_ADDRESS', 'CHANGEME'); define('API_ACCESS_TOKEN', 'CHANGEME'); define('EXTENSION_NUMBER', 'CHANGEME'); define('SANDBOX_NUMBER', 'CHANGEME'); // The parameters sent in the body of the request $data = array( 'extension' => EXTENSION_NUMBER, 'phoneCallView' => array(array( 'source' => EXTENSION_NUMBER, 'destination' => SANDBOX_NUMBER)) ); // Setup the requests parameters $options = array( CURLOPT_HTTPHEADER => array( 'Content-type: application/json', 'Authorization: Bearer '.API_ACCESS_TOKEN ), // URI that identifies the phone call CURLOPT_URL => 'https://'.VN_SERVER_ADDRESS.'/uapi/phoneCalls/@me/simple', CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_RETURNTRANSFER => true, CURLOPT_POSTFIELDS => json_encode($data) ); // Makes a HTTP POST request using SSL $ch = curl_init(); curl_setopt_array($ch, $options); // Parses the JSON response print_r(json_decode(curl_exec($ch),true)); |
...
The example below demonstrates how you can use Unified API to park a party of an ongoing phone call. It uses the the Park PhoneCalls request.
Code Block | ||
---|---|---|
| ||
<?php // Modify these values with the ones you intend to use define('VN_SERVER_ADDRESS', 'CHANGEME'); define('API_ACCESS_TOKEN', 'CHANGEME'); define('PHONECALL_ID', 'CHANGEME"'); define('PHONECALLVIEW_ID', 'CHANGEME'); define('EXTENSION_NUMBER', 'CHANGEME'); // The parameters sent in the body of the request $data = array( 'action' => 'Park', 'phoneCallViewId' => PHONECALLVIEW_ID ); // Setup the requests parameters $options = array( CURLOPT_HTTPHEADER => array( 'Content-type: application/json', 'Authorization: Bearer '.API_ACCESS_TOKEN ), CURLOPT_URL => 'https://'.VN_SERVER_ADDRESS.'/uapi/phoneCalls/@me/'. EXTENSION_NUMBER .'/'.PHONECALL_ID, CURLOPT_CUSTOMREQUEST => 'PUT', CURLOPT_RETURNTRANSFER => true, CURLOPT_POSTFIELDS => json_encode($data) ); // Makes a HTTP PUT request using SSL $ch = curl_init(); curl_setopt_array($ch, $options); // Parses the JSON response print_r(json_decode(curl_exec($ch),true)); |
...
The example below demonstrates how you can use Unified API to transfer a call to a public number, not registered with VoipNow. It uses the the Transfer PhoneCalls request.
...
The example below demonstrates how you can use Unified API to record an ongoing conversation. This action is possible for phone numbers that are registered with VoipNow. The recording is saved in the the wav format and uses the StartRecording PhoneCalls request.
...
Except where otherwise noted, content in this space is licensed under a Creative Commons Attribution 4.0 International.