vzaar API PHP client
vzaar API client for PHP developers.
vzaar is the go to video hosting platform for business. Affordable, customizable and secure. Leverage the power of online video and enable commerce with vzaar. For more details and signup please visit http://vzaar.com
Using the library
In order to start using vzaar API library
require_once 'Vzaar.php'; Vzaar::$token = 'VZAAR_API_TOKEN'; Vzaar::$secret = 'VZAAR_USERNAME';
For versions > 1.3.0, if you have installed the library through Composer, you may require the Composer autoload file instead of individual Vzaar source files. Composer will automatically find and load your classes when used:
require_once 'vendor/autoload.php'; Vzaar::$token = 'VZAAR_API_TOKEN'; Vzaar::$secret = 'VZAAR_USERNAME';
In order to use the vzaar API, you need to have a valid username and API token that you can get from your vzaar dashboard at http://app.vzaar.com/settings/api
To check you can connect via the API, you can run the following command:
If it returns your vzaar username, then you're good to go.
This API call returns the user's public details along with relevant metadata.
This API call returns a list of the user's active videos along with relevant metadata. 20 videos are returned by default, but this is customizable.
Vzaar::getVideoList('VZAAR_USERNAME', true, 10);
In this example, the
true parameter says that the API call should be authenticated. If you have your API settings set to 'private', then you will need to be authenticated.
This API call returns metadata about the selected video (dimensions, thumbnail information, author, duration, play count, etc).
In this case, VZAAR_VIDEO_ID is the unique vzaar video ID assigned to a video after its processing.
Special characters in filenames
As per the AWS S3 documentation, only a small number of special characters in filenames are supported: http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html
The following special characters are supported by the vzaar API:
- - (dash)
- . (dot)
- ! (exclamation)
- () (braces)
If you are performing your own uploading (e.g. a 3rd-party or custom uploader) you will need to generate an S3 upload signature. You can then use this in your custom uploader.
Vzaar::getUploadSignature(null, '/tmp/video.mp4', true, 'video.mp4', 102400);
As of version 1.3.0 the method signature for
getUploadSignature has changed. The new method expects additional arguments which are required to support multipart uploads.
$redirectUrl: if you are using redirection after your upload, specify redirect URL
$path: path to the source file
$multipart: if true, initiate a multipart upload
$filename: source file name
$filesize: source file size
Uploading and processing videos
Getting a video into your vzaar account is a two step process; you must first upload and then process the video.
Uploading videos from the filesystem
Use this method when you build desktop apps or when you upload videos to vzaar directly from your server.
$guid = Vzaar::uploadVideo("/path/to/file/video.mp4"); Vzaar::processVideo($guid, "Title", "Description", "labels"));
Uploading videos using a url
Uploading a new video or replacing an existing one from a url
$url = "http://www.mywebsite.com/my_video.mp4"; Vzaar::uploadLink($url, "Title");
This API call tells the vzaar system to process a newly uploaded video. This will provide a vzaar video ID, then encode the video if necessary.
Typically you only need to do this when performing your own uploads (see Upload Signature).
Vzaar::processVideo(GUID, TITLE, DESCRIPTION, LABELS, PROFILE);
GUID(string) - Specifies the guid to operate on. Get this from the result of your
TITLE(string) - Specifies the title for the video.
DESCRIPTION(string) - Specifies the description for the video.
LABELS(string) - Comma separated list of labels to be assigned to the video.
PROFILE(integer) - Specifies the size for the video to be encoded in. If not specified, this will use the vzaar default or the user default (if set). See
Upload thumbnails for a video by using the video id.
$video_id = 123; $thumb_path = "/path/to/file/image.jpg"; Vzaar::uploadThumbnail($video_id, $thumb_path);
Generate a thumbnail based on frame time.
$video_id = 123; Vzaar::generateThumbnail($video_id, 3);
This API call allows a user to edit or change details about a video.
Vzaar::editVideo(VIDEO_ID, VIDEO_TITLE, VIDEO_DESCRIPTION, MARK_AS_PRIVATE);
The following arguments should be passed to the method:
VIDEO_ID(integer) - Unique vzaar Video ID of the video you are going to modify
VIDEO_TITLE(string) - Specifies the new title for the video
VIDEO_DESCRIPTION(string) - Specifies the new description for the video
MARK_AS_PRIVATE(boolean) (true|false) - Marks the video as private or public
This API call allows you to delete a video from your account. If deletion was successful it will return true otherwise false.
Released under the MIT License.