Skip to content

Commit 4502782

Browse files
committed
Add Cloud example
1 parent 18e6284 commit 4502782

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

Diff for: example-cloud.php

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
/*
4+
* This library is free software, and it is part of the Active Collab SDK project. Check LICENSE for details.
5+
*
6+
* (c) A51 doo <[email protected]>
7+
*/
8+
9+
require_once __DIR__ . '/vendor/autoload.php';
10+
11+
$authenticator = new \ActiveCollab\SDK\Authenticator\Cloud('ACME Inc', 'My Awesome Application', '[email protected]', 'hard to guess, easy to remember');
12+
13+
// Show all Active Collab 5 and up account that this user has access to
14+
print_r($authenticator->getAccounts());
15+
16+
// Show user details (first name, last name and avatar URL)
17+
print_r($authenticator->getUser());
18+
19+
// Issue a token for account #123456789
20+
$token = $authenticator->issueToken(123456789);
21+
22+
if ($token instanceof \ActiveCollab\SDK\TokenInterface) {
23+
print $token->getUrl() . "\n";
24+
print $token->getToken() . "\n";
25+
} else {
26+
print "Invalid response\n";
27+
die();
28+
}
29+
30+
// Create a client instance
31+
$client = new \ActiveCollab\SDK\Client($token);
32+
33+
// Make a request
34+
print_r($client->get('projects')->getJson());

0 commit comments

Comments
 (0)