(PHP ActiveX) Activix CRM Upload a Recording
Upload a recording for an existing communication. For more information, see https://docs.crm.activix.ca/api/resources/communication
<?php
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
// For versions of Chilkat < 10.0.0, use new COM('Chilkat_9_5_0.Chilkat.HttpRequest')
$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 != 1) {
print $req->LastErrorText . "\n";
exit;
}
// For versions of Chilkat < 10.0.0, use new COM('Chilkat_9_5_0.Chilkat.Http')
$http = new COM("Chilkat.Http");
$http->AuthToken = 'ACCESS_TOKEN';
// resp is a Chilkat.HttpResponse
$resp = $http->SynchronousRequest('crm.activix.ca',443,1,$req);
if ($http->LastMethodSuccess != 1) {
print $http->LastErrorText . "\n";
exit;
}
print 'Response Status Code: ' . $resp->StatusCode . "\n";
// For versions of Chilkat < 10.0.0, use new COM('Chilkat_9_5_0.Chilkat.JsonObject')
$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."
// }
//
?>
|