When you are using FTP batch provisioning to upload videos to Video Cloud, you may want to be notified when the upload is complete. You can get notification by email, or you can use the callback feature, which sends upload notifications to the URL you specify.
To use the callback feature, include a <callback> element in the manifest file for your FTP batch upload. The <callback> element is a child of the top-level publisher-upload-manifest element. It has a single attribute, entity-url, whose value is the URL you want the upload status posted to.
<callback entity-url="http://example.com/batch-callback.php"/>
You will receive notification only of failures, not successes, unless you have set the attribute report-success="true" in the publisher-upload-manifest tag of your manifest.
Each time a tag is executed in a manifest, the Video Cloud system initiates a POST request, just like when you submit a form, and sends it to the URL you specified in the manifest. The following key/values (form data) are sent in the request:
| Key | Value |
|---|---|
| referenceId | the reference id provided in the manifest |
| id | the id of the video, playlist, or asset in the database |
| entity | VIDEO, LINEUP (playlist), or ASSET |
| action | CREATE, DELETE, or UPDATE |
| status | FAILED or SUCCESS |
| error | An error message |
When the data arrives, you need to do something with these values. Any server side language will likely be able to function as a listener for these requests.
The most common actions to take would be to append these values to a log file, insert these values as a row in a database, or send an email that contains the same information. In this example, we'll use a PHP script to listen for these values and then write them to a log file. You can download a zip file that includes the PHP script.
Here is a snippet from the code to show you exactly what is happening
<?php
// Begin by checking to see if "referenceId" is included in the POST request.
// If it is, assign its value to the $referenceId Variable.
// If it is not, assign the value of null to $referenceId.
if(isset($_POST["referenceId"])) {
$referenceId = $_POST["referenceId"];
} else {
$referenceId = null;
}
/* Repeat the same code for each key in the request */
// Next build a string that contrains the current date and time as well as
// the value for each key that was included in the request seperated by
// a comma so that it can easily be imported as a CSV file.
//
$logEntry = date("m-d-y H:i:s") . ": " .
$referenceId . "," .
$id . "," .
$entity . "," .
$action . "," .
$status . "," .
$error .
"\n";
// Lastly, tell PHP where it can find the log file and tell PHP to open it
// and add the string we created earlier to it.
$logFileLocation = "log.txt";
$fileHandle = fopen($logFileLocation, 'a') or die("-1");
fwrite($fileHandle, $logEntry);
fclose($fileHandle);
?>
This will result in a log file that looks like this:
06-04-11 17:42:34: 123456789ref,123456789,VIDEO,CREATE,FAILED, (continued) This failed because it was just a test 06-04-11 17:42:35: 123456790ref,123456790,VIDEO,CREATE,FAILED, (continued) This failed because it was just a test 06-04-11 17:42:36: 123456791ref,123456791,VIDEO,CREATE,FAILED, (continued) This failed because it was just a test 06-04-11 17:42:37: 123456792ref,123456792,VIDEO,UPDATE,SUCCESS, 06-04-11 17:42:40: 123456793ref,123456793,VIDEO,UPDATE,SUCCESS, 06-04-11 17:42:41: 123456794ref,123456794,VIDEO,DELETE,SUCCESS, 06-04-11 17:42:42: 123456795ref,123456795,VIDEO,DELETE,SUCCESS,