forked from activecollab/activecollab-feather-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example-self-hosted.php
29 lines (22 loc) · 880 Bytes
/
example-self-hosted.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
<?php
/*
* This library is free software, and it is part of the Active Collab SDK project. Check LICENSE for details.
*
* (c) A51 doo <info@activecollab.com>
*/
require_once __DIR__ . '/vendor/autoload.php';
// Construct a self-hosted authenticator. Last parameter is URL where your Active Collab
$authenticator = new \ActiveCollab\SDK\Authenticator\SelfHosted('ACME Inc', 'My Awesome Application', 'you@acmeinc.com', 'hard to guess, easy to remember', 'https://my.company.com/projects');
// Issue a token
$token = $authenticator->issueToken();
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());