Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reports api #17

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update README with reports api
Cyril Tata authored and Cyril Tata committed Mar 11, 2014
commit 6798ce4a331ab3bb6b44929fdad113b148e92b6f
74 changes: 74 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -30,6 +30,8 @@ called:
$zencoder->inputs->details($input_id);
$zencoder->outputs->details($output_id);
$zencoder->notifications->parseIncoming();
$zencoder->reports->vod($array);
$zencoder->reports->all($array);

Any errors will throw a Services_Zencoder_Exception. You can call getErrors() on an exception
and it will return any errors received from the Zencoder API.
@@ -175,6 +177,78 @@ Then submit the job to test if it works.
Modify the above script to meet your needs.
Your [notifications page](https://app.zencoder.com/notifications) will come in handy.

REPORTS
----------------------
The ZencoderReports class is used to get reports over the zencoder api.
See [reports api doc](https://app.zencoder.com/docs/api/reports) for required/optional parameters.

### Get usage for VOD
Create a script to get usage for VOD

#### Example
<?php

// Make sure this points to a copy of Zencoder.php on the same server as this script.
require_once('Services/Zencoder.php');

// Initialize the Services_Zencoder class
$zencoder = new Services_Zencoder('93h630j1dsyshjef620qlkavnmzui3');

// Get reports
$params = array(
'from' => '2014-02-01',
'to' => '2014-02-28',
)
$reports = $zencoder->reports->vod($params);
// for live reports you just call the 'live' method i.e $reports = $zencoder->reports->live($params) ($params is optional)

if ($reports->statistics) {
foreach ($reports->statistics as $statistic) {
print_r($statistic);
}
print_r($reports->total);
} else {
echo "no statistics found";
}

?>

### Get usage for VOD & Live
Get reports containing a breakdown of VOD and live-streaming usage.

**see return structure at:**
<https://app.zencoder.com/docs/api/reports/all>

#### Example
<?php

// Make sure this points to a copy of Zencoder.php on the same server as this script.
require_once('Services/Zencoder.php');

// Initialize the Services_Zencoder class
$zencoder = new Services_Zencoder('93h630j1dsyshjef620qlkavnmzui3');

// Get reports
$params = array(
'from' => '2014-02-01',
'to' => '2014-02-28',
)
$reports = $zencoder->reports->all($params);

// $reports->statistics if not empty will be an array with keys 'vod' and 'live' (same for $reports->total)

if (!empty($reports->statistics['vod'])) {
foreach ($reports->statistics['vod'] as $statistic) {
print_r($statistic);
}
print_r($reports->total['vod']);
} else {
echo "no vod statistics found";
}

?>


VERSIONS
---------
Version 2.1.1 - 2012-08-02 Fixing issue where jobs index call didn't return jobs as individual objects