Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add access to reports API#36

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
glensc wants to merge1 commit intozencoder:master
base:master
Choose a base branch
Loading
fromglensc:cyril-reports-api
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
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
2 changes: 1 addition & 1 deletion.gitignore
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
test.php
build_docs.sh
.DS_Store

/nbproject/
40 changes: 40 additions & 0 deletionsREADME.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -84,6 +84,7 @@ $zencoder->jobs->progress($job_id);
$zencoder->inputs->details($input_id);
$zencoder->outputs->details($output_id);
$zencoder->notifications->parseIncoming();
$zencoder->reports->details($report_type, $optional_params);
```

Any errors will throw a Services_Zencoder_Exception. You can call getErrors() on an exception
Expand DownExpand Up@@ -249,6 +250,45 @@ 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 ALL reports
Create a script to get reports for a specified date range

#### 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',
)

// 'all' can be replaced by 'vod' or 'live' acccording to entry points in docs
$report = $zencoder->reports->details('all', $params);

// Each reports object should have a 'statistics' and 'total' base element
if ($report->statistics) {
foreach ($report->statistics as $statistic) {
print_r($statistic);
}
print_r($report->total);
} else {
echo "no statistics found";
}

```


VERSIONS
---------

Expand Down
9 changes: 9 additions & 0 deletionsServices/Zencoder.php
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -88,6 +88,14 @@ class Services_Zencoder extends Services_Zencoder_Base
* @var Services_Zencoder_Outputs
*/
public $outputs;
/**
* Provides access to the Zencoder Reports API
*
* Valid functions: vod, live, minutes, all
*
* @var Services_Zencoder_Reports
*/
public $reports;

/**
* Initialize the Services_Zencoder class and sub-classes.
Expand DownExpand Up@@ -135,6 +143,7 @@ public function __construct(
$this->jobs = new Services_Zencoder_Jobs($this);
$this->notifications = new Services_Zencoder_Notifications($this);
$this->outputs = new Services_Zencoder_Outputs($this);
$this->reports = new Services_Zencoder_Reports($this);
}

/**
Expand Down
51 changes: 51 additions & 0 deletionsServices/Zencoder/Report.php
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
<?php

/**
* Zencoder API client interface.
*
* @category Services
* @package Services_Zencoder
* @author Cyril Tata <cyril.tata@ekspressdigital.eu>
* @version Release: 2.1.2
* @license http://creativecommons.org/licenses/MIT/MIT
* @link http://github.com/zencoder/zencoder-php
*/
class Services_Zencoder_Report extends Services_Zencoder_Object
{
/**
* Statistics of a report
*
* @var object
*/
public $statistics;

/**
* Totals of a of report
*
* @var object
*/
public $total;

/**
* A copy of the raw API response for debug purposes
*
* @var mixed
*/
protected $raw_response;

/**
* Create a new Services_Zencoder_Report object.
* For attributes of the various kinds of reports, see
* @link https://app.zencoder.com/docs/api/reports/vod
* @link https://app.zencoder.com/docs/api/reports/live
* @link https://app.zencoder.com/docs/api/reports/all
*
* @param mixed $params API response
* @param string $type The type of statistic we are fetching
*/
public function __construct($params)
{
$this->raw_response = $params;
parent::__construct($params);
}
}
33 changes: 33 additions & 0 deletionsServices/Zencoder/Reports.php
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
<?php

/**
* Zencoder API client interface.
*
* @category Services
* @package Services_Zencoder
* @author Cyril Tata <cyril.tata@ekspressdigital.eu>
* @version Release: 2.1.2
* @license http://creativecommons.org/licenses/MIT/MIT
* @link http://github.com/zencoder/zencoder-php
*/
class Services_Zencoder_Reports extends Services_Zencoder_Base
{
/**
* Get details about different types of reports
*
* @link https://app.zencoder.com/docs/api/reports
*
* @param string $report_type The type of report to get. The following are currently supported over the api
* - 'all' : Returns all reports, both VOD and LIVE
* - 'vod' : Returns VOD reports
* - 'live': Return LIVE reports
* @param array $params An associated array of optional query parameters per requested report type
* @param array $opts Optional overrides
*
* @return Services_Zencoder_Report The object representation of the resource
*/
public function details($report_type = 'all', $params = array(), $opts = array())
{
return new Services_Zencoder_Report($this->proxy->retrieveData("reports/$report_type", $params, $opts));
}
}

[8]ページ先頭

©2009-2025 Movatter.jp