-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patheventsapi.php
More file actions
42 lines (33 loc) · 1.15 KB
/
eventsapi.php
File metadata and controls
42 lines (33 loc) · 1.15 KB
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
# For more information, check out our support page
# https://support.1password.com/events-reporting
$api_token = getenv('EVENTS_API_TOKEN');
$url = "https://events.1password.com";
$start_time = (new \DateTime())->modify('-24 hours');
$headers = array(
"Content-Type: application/json",
"Authorization: Bearer $api_token"
);
$payload = array(
"limit" => 20,
"start_time" => $start_time->format('Y-m-d\TH:i:s\Z')
);
# Alternatively, use the cursor returned from previous responses to get any new events
# $payload = array("cursor" => $cursor);
$context = stream_context_create(
array(
'http' => array(
'method' => 'POST',
'content' => json_encode($payload),
'header' => $headers,
)
)
);
$signin_attempts = file_get_contents($url."/api/v1/signinattempts", false, $context);
print($signin_attempts);
$item_usages = file_get_contents($url."/api/v1/itemusages", false, $context);
print($item_usages);
$audit_events = file_get_contents($url."/api/v1/auditevents", false, $context);
print($audit_events);
# For more information on the response, check out our support page
# https://support.1password.com/cs/events-api-reference/