-
Notifications
You must be signed in to change notification settings - Fork 2
/
sign-api.php
42 lines (36 loc) · 1.23 KB
/
sign-api.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
<?php
require __DIR__ . '/../vendor/autoload.php';
$api = new \Smartlook\Webapi\Client();
// create account with your <authKey>
$signResult = $api->signUp(array(
'authKey' => '<authKey>',
'email' => '<unique_login_email>',
'password' => '123456',
'lang' => 'en'
));
if (!$signResult['ok']) {
exit($signResult['error'] . ' ' . $signResult['message'] . PHP_EOL);
}
// use account <apiKey> to access other methods
$api->authenticate($signResult['account']['apiKey']);
// create first project
$projectResult = $api->projectsCreate(array(
'name' => 'my first project'
));
if (!$projectResult['ok']) {
exit($projectResult['error'] . ' ' . $projectResult['message'] . PHP_EOL);
}
printf("Created project: %s\n", $projectResult['project']['id']);
printf("Project key for websites: %s\n", $projectResult['project']['key']);
// fetch sessions of project
$sessionsResult = $api->sessionsList(array(
'projectId' => $projectResult['project']['id'],
'filters' => array(
'timeStartSince' => '2017-06-12',
'timeStartUntil' => '2017-06-20'
)
));
if (!$sessionsResult['ok']) {
exit($sessionsResult['error'] . ' ' . $sessionsResult['message'] . PHP_EOL);
}
printf("Found %s sessions of project %s\n", $sessionsResult['total'], $projectResult['project']['id']);