forked from muxinc/mux-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexercise-video-views.php
29 lines (24 loc) · 1.01 KB
/
exercise-video-views.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
require_once(__DIR__ . '/../assert.php');
require_once 'vendor/autoload.php';
// Exercises all video view operations.
// Authentication Setup
$config = MuxPhp\Configuration::getDefaultConfiguration()
->setUsername(getenv('MUX_TOKEN_ID'))
->setPassword(getenv('MUX_TOKEN_SECRET'));
// API Client Initialization
$viewsApi = new MuxPhp\Api\VideoViewsApi(
new GuzzleHttp\Client(),
$config
);
# ========== list-video-views ==========
$views = $viewsApi->listVideoViews(["filters" => ['country:US', 'browser:Safari'], "timeframe" => ['7:days']]);
assert($views->getData() !== null);
assert(sizeof($views->getData()) > 0);
assert($views->getData()[0]->getId() !== null);
print("list-video-views OK ✅\n");
# ========== get-video-view ==========
$view = $viewsApi->getVideoView($views->getData()[0]->getId());
assert($view->getData() !== null);
assert($view->getData()->getId() !== null);
print("get-video-view OK ✅\n");