Documentation

What if you wanted to work with the videos through the API + from your PHP server codes? Well with Ziggeo that is very simple and here you will see more about how exactly you can do that.

You will see each method available and then example code that you can check to see a working example of the same.

Fork me on GitHub
  • index
    Query an array of videos (will return at most 50 videos by default). Newest videos come first.
    $ziggeo->videos()->index($arguments = array())
    
    1. limit Limit the number of returned videos. Can be set up to 100.
    2. skip Skip the first [n] entries.
    3. reverse Reverse the order in which videos are returned.
    4. states Filter videos by state
    5. tags Filter the search result to certain tags, encoded as a comma-separated string
    This method returns JSON
    [
    	{
    	"volatile":false,
    	"token":"a7edab8c635ec37047d8ae75411528e3",
    	"key":null,
    	"state":5,
    	"max_duration":null,
    	"duration":1,
    	"tags":null,
    	"submission_date":1390257799,
    	"resubmission_date":1390257799,
    	"stream_submission_date":1390257799,
    	"delete_old_streams":true,
    	"type":"ApiVideo",
    	"created":1390257798,
    	"owned":false,
    	"state_string":"READY",
    	"streams":[
    	{
    		"volatile":false,
    		"token":"d751140b4e1cf0a243f32092f6110296",
    		"key":null,
    		"creation_type":5,
    		"state":5,
    		"streamable":2,
    		"video_type":"mp4",
    		"video_sub_type":"other",
    		"image_size":0,
    		"video_size":36078,
    		"video_width":640,
    		"video_height":360,
    		"duration":1,
    		"has_video":true,
    		"has_image":true,
    		"submission_date":1390257799,
    		"type":"ApiVideoStream",
    		"created":1390257799,
    		"owned":true,
    		"creation_type_string":"SERVER_UPLOAD",
    		"streamable_string":"DEGRADED",
    		"state_string":"READY"
    	}],
    	"original_stream":
    	{
    		"volatile":false,
    		"token":"d751140b4e1cf0a243f32092f6110296",
    		"key":null,
    		"creation_type":5,
    		"state":5,
    		"streamable":2,
    		"video_type":"mp4",
    		"video_sub_type":"other",
    		"image_size":0,
    		"video_size":36078,
    		"video_width":640,
    		"video_height":360,
    		"duration":1,
    		"has_video":true,
    		"has_image":true,
    		"submission_date":1390257799,
    		"type":"ApiVideoStream",
    		"created":1390257799,
    		"owned":true,
    		"creation_type_string":"SERVER_UPLOAD",
    		"streamable_string":"DEGRADED",
    		"state_string":"READY"
    	},
    	"default_stream":
    	{
    		"volatile":false,
    		"token":"d751140b4e1cf0a243f32092f6110296",
    		"key":null,
    		"creation_type":5,
    		"state":5,
    		"streamable":2,
    		"video_type":"mp4",
    		"video_sub_type":"other",
    		"image_size":0,
    		"video_size":36078,
    		"video_width":640,
    		"video_height":360,
    		"duration":1,
    		"has_video":true,
    		"has_image":true,
    		"submission_date":1390257799,
    		"type":"ApiVideoStream",
    		"created":1390257799,
    		"owned":true,
    		"creation_type_string":"SERVER_UPLOAD",
    		"streamable_string":"DEGRADED",
    		"state_string":"READY"
    	}}]
    
    Example:
    <?php
    /*
    	This script will show you how you can get the list of videos from your account
    
    	Parameters you need to pass:
    	1. app_token
    	2. private_key
    */
    require_once(dirname(__FILE__) . "/../Ziggeo.php");
    
    $opts = getopt("", array("app_token:", "private_key:"));
    
    $ziggeo = new Ziggeo($opts["app_token"], $opts["private_key"]);
    
    $videos = array();
    $skip = 0;
    $limit = 100;
    
    do {
    	$videos = $ziggeo->videos()->index(array(
    		"skip" => $skip,
    		"limit" => $limit
    	));
    
    	//we go through all of the found videos
    	foreach ($videos as $video) {
    		//We print out the list of the videos we found
    		echo "Listing " . $video["token"] . " / " . @$video["key"] . "\n";
    		$skip++; //We use this for the index purposes (code at start of do loop)
    	}
    } while (count($videos) > 0);
    
    ?>
    
  • count
    Get the video count for the application.
    $ziggeo->videos()->count($arguments = array())
    
    1. states Filter videos by state
    2. tags Filter the search result to certain tags, encoded as a comma-separated string
    This method returns JSON
    Example:
    <?php
    /*
    	This script will show you how you can get the number of all videos in your application
    
    	Parameters you need to pass:
    	1. app_token
    	2. private_key
    */
    require_once(dirname(__FILE__) . "/../Ziggeo.php");
    
    $opts = getopt("", array("app_token:", "private_key:"));
    
    $ziggeo = new Ziggeo($opts["app_token"], $opts["private_key"]);
    
    $result = $ziggeo->videos()->count();
    
    var_dump($result);
    
    ?>
    
  • get
    Get a single video by token or key.
    $ziggeo->videos()->get($token_or_key)
    
    This method returns JSON
    {
    	"volatile":false,
    	"token":"a7edab8c635ec37047d8ae75411528e3",
    	"key":null,
    	"state":5,
    	"max_duration":null,
    	"duration":1,
    	"tags":null,
    	"submission_date":1390257799,
    	"resubmission_date":1390257799,
    	"stream_submission_date":1390257799,
    	"delete_old_streams":true,
    	"type":"ApiVideo",
    	"created":1390257798,
    	"owned":false,
    	"state_string":"READY",
    	"streams":[
    	{
    		"volatile":false,
    		"token":"d751140b4e1cf0a243f32092f6110296",
    		"key":null,
    		"creation_type":5,
    		"state":5,
    		"streamable":2,
    		"video_type":"mp4",
    		"video_sub_type":"other",
    		"image_size":0,
    		"video_size":36078,
    		"video_width":640,
    		"video_height":360,
    		"duration":1,
    		"has_video":true,
    		"has_image":true,
    		"submission_date":1390257799,
    		"type":"ApiVideoStream",
    		"created":1390257799,
    		"owned":true,
    		"creation_type_string":"SERVER_UPLOAD",
    		"streamable_string":"DEGRADED",
    		"state_string":"READY"
    	}],
    	"original_stream":
    	{
    		"volatile":false,
    		"token":"d751140b4e1cf0a243f32092f6110296",
    		"key":null,
    		"creation_type":5,
    		"state":5,
    		"streamable":2,
    		"video_type":"mp4",
    		"video_sub_type":"other",
    		"image_size":0,
    		"video_size":36078,
    		"video_width":640,
    		"video_height":360,
    		"duration":1,
    		"has_video":true,
    		"has_image":true,
    		"submission_date":1390257799,
    		"type":"ApiVideoStream",
    		"created":1390257799,
    		"owned":true,
    		"creation_type_string":"SERVER_UPLOAD",
    		"streamable_string":"DEGRADED",
    		"state_string":"READY"
    	},
    	"default_stream":
    	{
    		"volatile":false,
    		"token":"d751140b4e1cf0a243f32092f6110296",
    		"key":null,
    		"creation_type":5,
    		"state":5,
    		"streamable":2,
    		"video_type":"mp4",
    		"video_sub_type":"other",
    		"image_size":0,
    		"video_size":36078,
    		"video_width":640,
    		"video_height":360,
    		"duration":1,
    		"has_video":true,
    		"has_image":true,
    		"submission_date":1390257799,
    		"type":"ApiVideoStream",
    		"created":1390257799,
    		"owned":true,
    		"creation_type_string":"SERVER_UPLOAD",
    		"streamable_string":"DEGRADED",
    		"state_string":"READY"
    	}}
    
    Example:
    <?php
    /*
    	This script will show you how you can get details about a single video
    
    	Parameters you need to pass:
    	1. app_token
    	2. private_key
    	3. video_token
    */
    require_once(dirname(__FILE__) . "/../Ziggeo.php");
    
    $opts = getopt("", array("app_token:", "private_key:", "video_token:"));
    
    $ziggeo = new Ziggeo($opts["app_token"], $opts["private_key"]);
    
    $result = $ziggeo->videos()->get($opts["video_token"]);
    
    var_dump($result);
    
    ?>
    
  • get_bulk
    Get multiple videos by tokens or keys.
    $ziggeo->videos()->get_bulk($arguments = array())
    
    1. tokens_or_keys Comma-separated list with the desired videos tokens or keys (Limit: 100 tokens or keys).
    This method returns JSON
    Example:
    <?php
    /*
    	This script will show you how you can get details about a multiple videos in the same time
    
    	Parameters you need to pass:
    	1. app_token
    	2. private_key
    	3. video_tokens
    */
    require_once(dirname(__FILE__) . "/../Ziggeo.php");
    
    $opts = getopt("", array("app_token:", "private_key:", "video_tokens:"));
    
    $ziggeo = new Ziggeo($opts["app_token"], $opts["private_key"]);
    
    $result = $ziggeo->videos()->get_bulk(array("tokens_or_keys" => $opts["video_tokens"]));
    
    var_dump($result);
    
    ?>
    
  • stats_bulk
    Get stats for multiple videos by tokens or keys.
    $ziggeo->videos()->stats_bulk($arguments = array())
    
    1. tokens_or_keys Comma-separated list with the desired videos tokens or keys (Limit: 100 tokens or keys).
    2. summarize Boolean. Set it to TRUE to get the stats summarized. Set it to FALSE to get the stats for each video in a separate array. Default: TRUE.
    This method returns JSON
  • download_video
    Download the video data file
    $ziggeo->videos()->download_video($token_or_key)
    
    This method returns DATA
    Example:
    <?php
    /*
    	This script will show you how you can download the video
    
    	Parameters you need to pass:
    	1. app_token
    	2. private_key
    	3. video_token
    */
    require_once(dirname(__FILE__) . "/../Ziggeo.php");
    
    $opts = getopt("", array("app_token:", "private_key:", "video_token:"));
    
    $ziggeo = new Ziggeo($opts["app_token"], $opts["private_key"]);
    
    $file_content = $ziggeo->videos()->download_video($opts["video_token"]) ;
    
    file_put_contents('video.mp4', $file_content);
    
    ?>
    
  • download_image
    Download the image data file
    $ziggeo->videos()->download_image($token_or_key)
    
    This method returns DATA
    Example:
    <?php
    /*
    	This script will show you how you can download the video
    
    	Parameters you need to pass:
    	1. app_token
    	2. private_key
    	3. video_token
    */
    require_once(dirname(__FILE__) . "/../Ziggeo.php");
    
    $opts = getopt("", array("app_token:", "private_key:", "video_token:"));
    
    $ziggeo = new Ziggeo($opts["app_token"], $opts["private_key"]);
    
    $file_content = $ziggeo->videos()->download_image($opts["video_token"]) ;
    
    file_put_contents('image.jpg', $file_content);
    
    ?>
    
  • get_stats
    Get the video's stats
    $ziggeo->videos()->get_stats($token_or_key)
    
    This method returns JSON
  • push_to_service
    Push a video to a provided push service.
    $ziggeo->videos()->push_to_service($token_or_key, $arguments = array())
    
    1. pushservicetoken Push Services's token (from the Push Services configured for the app)
    This method returns JSON
    Example:
    <?php
    /*
    	This script will show you how you can push a video to some auto push service you have previously configured.
    
    	You'll need to:
    	1. Create new integration in the dashboard
    	2. Then create push service using the integration on your application's dashboard
    	3. Grab the push service token and use it here.
    
    	Parameters you need to pass:
    	1. app_token
    	2. private_key
    	3. video_token
    	4. push_service_token
    */
    require_once(dirname(__FILE__) . "/../Ziggeo.php");
    
    $opts = getopt("", array("app_token:", "private_key:", "video_token:", "push_service_token:"));
    
    if (empty($opts["push_service_token"])) {
    	die ("Must provide a push service token");
    }
    
    //We initialize our SDK
    $ziggeo = new Ziggeo($opts["app_token"], $opts["private_key"]);
    
    $data = array(
    	"pushservicetoken" => $opts["push_service_token"]
    );
    
    $ziggeo->videos()->push_to_service($opts["video_token"], $data);
    
    ?>
    
  • apply_effect
    Apply an effect profile to a video.
    $ziggeo->videos()->apply_effect($token_or_key, $arguments = array())
    
    1. effectprofiletoken Effect Profile token (from the Effect Profiles configured for the app)
    This method returns JSON
    Example:
    <?php
    /*
    	This script will show you how to apply an effect on your existing video
    
    	Parameters you need to pass:
    	1. app_token
    	2. private_key
    	3. video_token
    	4. effect_profile_token
    */
    require_once(dirname(__FILE__) . "/../Ziggeo.php");
    
    $opts = getopt("", array("app_token:", "private_key:", "video_token:", "effect_profile_token:"));
    
    //We initialize our SDK
    $ziggeo = new Ziggeo($opts["app_token"], $opts["private_key"]);
    
    $result = $ziggeo->videos()->apply_effect($opts["video_token"], array(
    	"effectprofiletoken" => $opts["effect_profile_token"]
    ));
    
    var_dump($result);
    
    ?>
    
  • apply_meta
    Apply a meta profile to a video.
    $ziggeo->videos()->apply_meta($token_or_key, $arguments = array())
    
    1. metaprofiletoken Meta Profile token (from the Meta Profiles configured for the app)
    This method returns JSON
    Example:
    <?php
    /*
    	This script will show you how to apply a meta profile to your existing video
    
    	Parameters you need to pass:
    	1. app_token
    	2. private_key
    	3. video_token
    	4. meta_profile_token
    */
    require_once(dirname(__FILE__) . '/../Ziggeo.php');
    
    $opts = getopt('', array('app_token:', 'private_key:', 'video_token:', 'meta_profile_token:'));
    
    //We initialize our SDK
    $ziggeo = new Ziggeo($opts['app_token'], $opts['private_key']);
    
    //Must be token, can not be a key
    $arguments = array(
    	'metaprofiletoken' => $opts['meta_profile_token']
    );
    
    $result = $ziggeo->videos()->apply_meta($opts['video_token'], $arguments);
    
    var_dump($result);
    
    ?>
    
  • update
    Update single video by token or key.
    $ziggeo->videos()->update($token_or_key, $arguments = array())
    
    1. min_duration Minimal duration of video
    2. max_duration Maximal duration of video
    3. tags Video Tags
    4. key Unique (optional) name of video
    5. volatile Automatically removed this video if it remains empty
    6. expiration_days After how many days will this video be deleted
    7. expire_on On which date will this video be deleted. String in ISO 8601 format: YYYY-MM-DD
    This method returns JSON
    {
    	"volatile":false,
    	"token":"a7edab8c635ec37047d8ae75411528e3",
    	"key":"brandnewname",
    	"state":5,
    	"max_duration":"10",
    	"duration":1,
    	"tags":null,
    	"submission_date":1390257799,
    	"resubmission_date":1390257799,
    	"stream_submission_date":1390257799,
    	"delete_old_streams":true,
    	"type":"ApiVideo",
    	"created":1390257798,
    	"owned":false,
    	"state_string":"READY",
    	"streams":[
    	{
    		"volatile":false,
    		"token":"d751140b4e1cf0a243f32092f6110296",
    		"key":null,
    		"creation_type":5,
    		"state":5,
    		"streamable":2,
    		"video_type":"mp4",
    		"video_sub_type":"other",
    		"image_size":0,
    		"video_size":36078,
    		"video_width":640,
    		"video_height":360,
    		"duration":1,
    		"has_video":true,
    		"has_image":true,
    		"submission_date":1390257799,
    		"type":"ApiVideoStream",
    		"created":1390257799,
    		"owned":true,
    		"creation_type_string":"SERVER_UPLOAD",
    		"streamable_string":"DEGRADED",
    		"state_string":"READY"
    	}],
    	"original_stream":
    	{
    		"volatile":false,
    		"token":"d751140b4e1cf0a243f32092f6110296",
    		"key":null,
    		"creation_type":5,
    		"state":5,
    		"streamable":2,
    		"video_type":"mp4",
    		"video_sub_type":"other",
    		"image_size":0,
    		"video_size":36078,
    		"video_width":640,
    		"video_height":360,
    		"duration":1,
    		"has_video":true,
    		"has_image":true,
    		"submission_date":1390257799,
    		"type":"ApiVideoStream",
    		"created":1390257799,
    		"owned":true,
    		"creation_type_string":"SERVER_UPLOAD",
    		"streamable_string":"DEGRADED",
    		"state_string":"READY"
    	},
    	"default_stream":
    	{
    		"volatile":false,
    		"token":"d751140b4e1cf0a243f32092f6110296",
    		"key":null,
    		"creation_type":5,
    		"state":5,
    		"streamable":2,
    		"video_type":"mp4",
    		"video_sub_type":"other",
    		"image_size":0,
    		"video_size":36078,
    		"video_width":640,
    		"video_height":360,
    		"duration":1,
    		"has_video":true,
    		"has_image":true,
    		"submission_date":1390257799,
    		"type":"ApiVideoStream",
    		"created":1390257799,
    		"owned":true,
    		"creation_type_string":"SERVER_UPLOAD",
    		"streamable_string":"DEGRADED",
    		"state_string":"READY"
    	}}
    
    Example:
    <?php
    /*
    	This script will show you how to approve the video through API call through the update call
    
    	Parameters you need to pass:
    	1. app_token
    	2. private_key
    	3. video_token
    	4. tags
    */
    require_once(dirname(__FILE__) . "/../Ziggeo.php");
    
    $opts = getopt("", array("app_token:", "private_key:", "video_token:", "tags:"));
    
    //We initialize our SDK
    $ziggeo = new Ziggeo($opts["app_token"], $opts["private_key"]);
    
    $ziggeo->videos()->update($opts["video_token"], array(
    	"tags" => $opts['tags']
    ));
    
    ?>
    
  • update_bulk
    Update multiple videos by token or key.
    $ziggeo->videos()->update_bulk($arguments = array())
    
    1. tokens_or_keys Comma-separated list with the desired videos tokens or keys (Limit: 100 tokens or keys).
    2. min_duration Minimal duration of video
    3. max_duration Maximal duration of video
    4. tags Video Tags
    5. volatile Automatically removed this video if it remains empty
    6. expiration_days After how many days will this video be deleted
    7. expire_on On which date will this video be deleted. String in ISO 8601 format: YYYY-MM-DD
    This method returns JSON
    Example:
    <?php
    /*
    	This script shows you how the update_bulk works, allowing you to update several videos in the same time
    
    	Parameters you need to pass:
    	1. app_token
    	2. private_key
    	3. video_tokens
    	4. tags
    */
    require_once(dirname(__FILE__) . "/../Ziggeo.php");
    
    $opts = getopt("", array("app_token:", "private_key:", "video_tokens:", "tags:"));
    
    //We initialize our SDK
    $ziggeo = new Ziggeo($opts["app_token"], $opts["private_key"]);
    
    $result = $ziggeo->videos()->update_bulk(array(
    	"tokens_or_keys" => $opts["video_tokens"],
    	"tags" => isset($opts["tags"]) ? $opts["tags"] : null
    ));
    
    var_dump($result);
    
    ?>
    
  • delete
    Delete a single video by token or key.
    $ziggeo->videos()->delete($token_or_key)
    
    Example:
    <?php
    /*
    	This script will show you how you can delete the specific video
    
    	Parameters you need to pass:
    	1. app_token
    	2. private_key
    	3. video_token
    */
    require_once(dirname(__FILE__) . "/../Ziggeo.php");
    
    $opts = getopt("", array("app_token:", "private_key:", "video_token:"));
    
    $ziggeo = new Ziggeo($opts["app_token"], $opts["private_key"]);
    
    $ziggeo->videos()->delete($opts["video_token"]);
    
    ?>
    
  • delete_file
    Delete video file only (keeps the data) by providing video token or key.
    $ziggeo->videos()->delete_file($token_or_key)
    
  • create
    Create a new video.
    $ziggeo->videos()->create($arguments = array())
    
    1. file Video file to be uploaded
    2. min_duration Minimal duration of video
    3. max_duration Maximal duration of video
    4. tags Video Tags
    5. key Unique (optional) name of video
    6. volatile Automatically removed this video if it remains empty
    7. effect_profile Set the effect profile that you want to have applied to your video.
    8. meta_profile Set the meta profile that you want to have applied to your video once created.
    9. video_profile Set the video profile that you want to have applied to your video as you create it.
    This method returns JSON
    {
    	"volatile":true,
    	"token":"a7edab8c635ec37047d8ae75411528e3",
    	"key":null,
    	"state":3,
    	"max_duration":null,
    	"duration":null,
    	"tags":null,
    	"submission_date":null,
    	"resubmission_date":null,
    	"stream_submission_date":null,
    	"delete_old_streams":true,
    	"type":"ApiVideo",
    	"created":1390257798,
    	"owned":false,
    	"state_string":"EMPTY",
    	"streams":[],
    	"original_stream":null,
    	"default_stream":null
    }
    
    Example:
    <?php
    /*
    	This script will show you how you can create a video by uploading a file
    
    	Parameters you need to pass:
    	1. app_token
    	2. private_key
    	3. filename
    */
    require_once(dirname(__FILE__) . "/../Ziggeo.php");
    
    $opts = getopt("", array("app_token:", "private_key:", "filename:"));
    
    $ziggeo = new Ziggeo($opts["app_token"], $opts["private_key"]);
    
    $ziggeo->videos()->create(array(
    	"file" => $opts["filename"] //path and name with extension
    ));
    
    ?>
    
  • analytics
    Get analytics for a specific videos with the given params
    $ziggeo->videos()->analytics($token_or_key, $arguments = array())
    
    1. from A UNIX timestamp in microseconds used as the start date of the query
    2. to A UNIX timestamp in microseconds used as the end date of the query
    3. date A UNIX timestamp in microseconds to retrieve data from a single date. If set, it overwrites the from and to params.
    4. query The query you want to run. It can be one of the following: device_views_by_os, device_views_by_date, total_plays_by_country, full_plays_by_country, total_plays_by_hour, full_plays_by_hour, total_plays_by_browser, full_plays_by_browser
    This method returns JSON
    Example:
    <?php
    /*
    	This script will show you how to get analytics data for a specific video
    
    	Parameters you need to pass:
    	1. app_token
    	2. private_key
    	3. video_token
    	4. filter_query
    	5. filter_from
    	6. filter_to
    	7. filter_date
    */
    require_once(dirname(__FILE__) . "/../Ziggeo.php");
    
    $opts = getopt("", array("app_token:", "private_key:", "video_token:", "filter_query:", "filter_from:", "filter_to:", "filter_date::"));
    
    //We initialize our SDK
    $ziggeo = new Ziggeo($opts["app_token"], $opts["private_key"]);
    
    $arguments = array(
    	"query" => $opts["filter_query"] // can be any of: device_views_by_os, device_views_by_date,
    	                                 //   total_plays_by_country, full_plays_by_country, total_plays_by_hour,
    	                                 //   full_plays_by_hour, total_plays_by_browser, full_plays_by_browser
    );
    
    if(isset($opts["filter_from"])) {
    	$arguments['from'] = $opts["filter_from"];
    }
    if(isset($opts["filter_to"])) {
    	$arguments['to'] = $opts["filter_to"];
    }
    if(isset($opts["filter_date"])) {
    	$arguments['date'] = $opts["filter_date"];
    }
    
    $analytics = $ziggeo->videos()->analytics($opts["video_token"], $arguments);
    
    var_dump($analytics);
    
    ?>