forked from luzmo-official/luzmo-sdk-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example-embedding.php
59 lines (56 loc) · 2.32 KB
/
example-embedding.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
require 'vendor/autoload.php';
use Cumulio\Cumulio;
// Connect to Cumul.io API
$client = Cumulio::initialize('< Your API key >', '< Your API token >');
// On page requests of pages containing embedded dashboards, request an "authorization"
$dashboardId = '1d5db81a-3f88-4c17-bb4c-d796b2093dac';
$time = new DateTime();
$authorization = $client->create('authorization', array(
'type' => 'temporary',
// User restrictions
'expiry' => $time->modify('+5 minutes')->format('c'),
// Data & dashboard restrictions
'securables' => array('4db23218-1bd5-44f9-bd2a-7e6051d69166', 'f335be80-b571-40a1-9eff-f642a135b826', $dashboardId),
'filters' => array(
array(
'clause' => 'where',
'origin' => 'global',
'securable_id' => '4db23218-1bd5-44f9-bd2a-7e6051d69166',
'column_id' => '3e2b2a5d-9221-4a70-bf26-dfb85be868b8',
'expression' => '? = ?',
'value' => 'Damflex'
)
),
// Presentation options
'locale_id' => 'en',
'screenmode' => 'desktop'
));
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Cumul.io embedding example</title>
</head>
<body>
<div style="margin-left: 28px; width: 650px;">
<h1 style="font-weight: 200;">Cumul.io embedding example</h1>
<p>This page contains an example of an embedded dashboard of Cumul.io. The dashboard data is securely filtered server-side, so clients can only access data to which your application explicitly grants access (in this case, the "Damflex" product).</p>
<p>Try to resize your page to see the dashboard adapting to different screen modes.</p>
</div>
<div id="myDashboard"></div>
<script type="text/javascript">
(function(d, a, s, h, b, oa, rd) {
if (!d[b]) {oa = a.createElement(s), oa.async = 1; oa.src = h; rd = a.getElementsByTagName(s)[0]; rd.parentNode.insertBefore(oa, rd);}
d[b] = d[b] || {}; d[b].addDashboard = d[b].addDashboard || function(v) { (d[b].list = d[b].list || []).push(v) };
})(window, document, 'script', 'https://cdn-a.cumul.io/js/embed.min.js', 'Cumulio');
Cumulio.addDashboard({
dashboardId: '<?php echo $dashboardId; ?>'
, container: '#myDashboard'
, key: '<?php echo $authorization['id']; ?>'
, token: '<?php echo $authorization['token']; ?>'
});
</script>
</body>
</html>