forked from muxinc/mux-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exercise-video-views.php
33 lines (27 loc) · 1.05 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
30
31
32
33
<?php
assert_options(ASSERT_BAIL, true);
require_once 'vendor/autoload.php';
// Exercises all video view operations:
// list-video-views
// get-video-view
// 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:GB', 'browser:Chrome'], "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");
?>