Sample code for 30+ languages & platforms
PHP Extension

Activix CRM Upload a Recording

See more Activix CRM Examples

Upload a recording for an existing communication.

Chilkat PHP Extension Downloads

PHP Extension
<?php

include("chilkat.php");

$success = false;

// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

$req = new CkHttpRequest();

$req->put_HttpVerb('POST');
$req->put_Path('/api/v2/communications/COMMUNICATION_ID/recording');
$req->put_ContentType('multipart/form-data');

$req->AddHeader('Accept','application/json');

$pathToFileOnDisk = 'qa_data/CantinaBand3.wav';
$success = $req->AddFileForUpload('recording',$pathToFileOnDisk);
if ($success == false) {
    print $req->lastErrorText() . "\n";
    exit;
}

$http = new CkHttp();
$http->put_AuthToken('ACCESS_TOKEN');

$resp = new CkHttpResponse();
$success = $http->HttpSReq('crm.activix.ca',443,true,$req,$resp);
if ($success == false) {
    print $http->lastErrorText() . "\n";
    exit;
}

print 'Response Status Code: ' . $resp->get_StatusCode() . "\n";

$jsonResponse = new CkJsonObject();
$jsonResponse->Load($resp->bodyStr());
$jsonResponse->put_EmitCompact(false);
print $jsonResponse->emit() . "\n";

if ($resp->get_StatusCode() >= 300) {
    print 'Failed.' . "\n";
    exit;
}

// Sample output...

// {
//   "message": "Recording uploaded successfully."
// }
// 

?>