Situations may arise where you need to upload a media asset to VMIX directly without using an upload form. For example:
- When ingesting large sets of content and associated metadata programatically
- When intercepting the upload from a user first before passing it on to VMIX
In the event you need to upload videos programatically (instead of using an upload form or widget), you can hit the API directly and have it return a result in XML. You will need to generate an upload token to use in your upload script. For PHP, the code to do this is as follows:
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)");
curl_setopt($ch, CURLOPT_URL, 'http://upload.vmixcore.com/vmixcore/upload');
curl_setopt($ch, CURLOPT_POST, true);
// same as <input type="file" name="file_upload" />
$post = array(
"file_upload" => "@".$FILE_PATH, // replace with the path to the file being uploaded
"token" => 'TOKEN', // replace TOKEN with a real upload token for your account
"title" => $media->title,
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$response = simplexml_load_string(curl_exec($ch));
Using the code above, or equivalent code for other programming languages, you can interface with the VMIX upload servers directly, receiving return data about whether the upload was successful or an error occurred. If an error occurs, you will receive an error code and a description of the error. If the upload was successful, you will receive the newly created media ID.
For a list of upload parameters, refer to Customizing and Preparing an HTML-based Upload Form Before Embedding It.