-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathexample-cloud.php
34 lines (25 loc) · 993 Bytes
/
example-cloud.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
<?php
/*
* This library is free software, and it is part of the Active Collab SDK project. Check LICENSE for details.
*
* (c) A51 doo <[email protected]>
*/
require_once __DIR__ . '/vendor/autoload.php';
$authenticator = new \ActiveCollab\SDK\Authenticator\Cloud('ACME Inc', 'My Awesome Application', '[email protected]', 'hard to guess, easy to remember');
// Show all Active Collab 5 and up account that this user has access to
print_r($authenticator->getAccounts());
// Show user details (first name, last name and avatar URL)
print_r($authenticator->getUser());
// Issue a token for account #123456789
$token = $authenticator->issueToken(123456789);
if ($token instanceof \ActiveCollab\SDK\TokenInterface) {
print $token->getUrl() . "\n";
print $token->getToken() . "\n";
} else {
print "Invalid response\n";
die();
}
// Create a client instance
$client = new \ActiveCollab\SDK\Client($token);
// Make a request
print_r($client->get('projects')->getJson());