(PHP ActiveX) Activix CRM Upload a Recording
Upload a recording for an existing communication. Note: This example requires Chilkat v11.0.0 or greater. For more information, see https://docs.crm.activix.ca/api/resources/communication
<?php
$success = 0;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
$req = new COM("Chilkat.HttpRequest");
$req->HttpVerb = 'POST';
$req->Path = '/api/v2/communications/COMMUNICATION_ID/recording';
$req->ContentType = 'multipart/form-data';
$req->AddHeader('Accept','application/json');
$pathToFileOnDisk = 'qa_data/CantinaBand3.wav';
$success = $req->AddFileForUpload('recording',$pathToFileOnDisk);
if ($success == 0) {
print $req->LastErrorText . "\n";
exit;
}
$http = new COM("Chilkat.Http");
$http->AuthToken = 'ACCESS_TOKEN';
$resp = new COM("Chilkat.HttpResponse");
$success = $http->HttpSReq('crm.activix.ca',443,1,$req,$resp);
if ($success == 0) {
print $http->LastErrorText . "\n";
exit;
}
print 'Response Status Code: ' . $resp->StatusCode . "\n";
$jsonResponse = new COM("Chilkat.JsonObject");
$jsonResponse->Load($resp->BodyStr);
$jsonResponse->EmitCompact = 0;
print $jsonResponse->emit() . "\n";
if ($resp->StatusCode >= 300) {
print 'Failed.' . "\n";
exit;
}
// Sample output...
// {
// "message": "Recording uploaded successfully."
// }
//
?>
|