-
Notifications
You must be signed in to change notification settings - Fork 0
/
mobile_login.php
42 lines (38 loc) · 1.41 KB
/
mobile_login.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
include './lib.php';
echo "Developers.dokobit.com WS API Mobile ID login PHP example\n";
$url = 'https://developers.dokobit.com';
$accessToken = ''; //Enter valid developer access token here.
$phone = isset($argv[1])?$argv[1]:'+37060000666';
$code = isset($argv[1])?$argv[1]:'50001018865';
if (empty($accessToken)) {
echo "Access Token is required. Enter at line 5.\n";
exit;
}
echo "Requesting login:\n";
$prepared = request($url, $accessToken, 'v2/mobile/login', [
'code' => $code,
'phone' => $phone
]);
echo "Responded: [".$prepared['status']."]\n";
if ($prepared['status'] != 'ok') {
print_r($prepared);
exit;
}
echo "Token: [ " . $prepared['token'] . " ]\n";
echo "Your phone will receive Mobile ID authentication request with\nVerification code: [ " . $prepared['control_code'] . " ]\n";
echo "Requesting status:\n";
$time = 120;
while ($time > 0) {
$statusResponse = request($url, $accessToken, 'v2/mobile/login/status/' . $prepared['token'], [], false);
echo "Status: [".$statusResponse['status']."]\n";
if ($statusResponse['status'] == 'ok') {
print_r($statusResponse);
exit;
} elseif ($statusResponse['status'] == 'error') {
var_dump($statusResponse['message']);
exit;
}
sleep(2);
$time -=2;
}