<?php require 'vendor/autoload.php'; use Plivo\RestAPI; $auth_id = "Your AUTH_ID"; $auth_token = "Your AUTH_TOKEN"; $p = new RestAPI($auth_id, $auth_token); # To record a call $params = array('call_uuid' => "xxxxxxxxxxx", 'time_limit' => '40', 'callback_url' => "https://example.com/record_action/", 'callback_method' => "GET", 'transcriptionType' => 'auto', 'transcriptionUrl' => "https://example.com/transcription/", 'transcriptionMethod' => 'GET'); $resp = $p->record($params); print_r($resp); # To stop recording a call $params = array('call_uuid' => "xxxxxxxxxxx"); $resp = $p->stop_record($params); print_r($resp); # To record a conference call $params = array('conference_name' => "demo", 'callback_url' => "https://example.com/record_action/", 'callback_method' => "GET"); $resp = $p->record_conference($params); print_r($resp); # To stop recording a conference call $params = array('conference_name' => "demo"); $resp = $p->stop_record_conference($params); print_r($resp);
<!--recording_action.php--> <?php require 'vendor/autoload.php'; use Plivo\RestAPI; $digit = $_REQUEST['Digits']; $uuid = $_REQUEST['CallUUID']; print "Digit : {$digit}"; print "Call UUID : {$uuid}"; $auth_id = "Your AUTH_ID"; $auth_token = "Your AUTH_TOKEN"; $p = new RestAPI($auth_id, $auth_token); if ($digit == "1") { $params = array('call_uuid' => $uuid); $response = $p->record($params); print "URL : {$response['response']['url']}"; print "Recording ID : {$response['response']['recording_id']}"; print "API ID : {$response['response']['api_id']}"; print "Message : {$response['response']['message']}"; } else { print "invalid"; } /* Sample Output <Response> <GetDigits action="https://glacial-harbor-8656.herokuapp.com/testing.php/recording_action" method="GET" timeout="7" numDigits="1" retries="1" redirect="false"> <Speak>Press 1 to record this call</Speak> </GetDigits> <Wait length="10"/> </Response>