-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.php
38 lines (28 loc) · 885 Bytes
/
example.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
<?php
require_once 'vendor/autoload.php';
session_start();
use Brainfab\MoyGrafik\MoyGrafik;
$OAUTH2_CLIENT_ID = 'your client id';
$OAUTH2_CLIENT_SECRET = 'your client secret';
$client = new MoyGrafik();
$client->setClientId($OAUTH2_CLIENT_ID);
$client->setClientSecret($OAUTH2_CLIENT_SECRET);
if (empty($_SESSION['_token'])) {
$client->authenticate([
'grant_type' => 'password',
'username' => 'your email',
'password' => 'your password',
]);
$_SESSION['_token'] = $client->getAccessToken();
}
if (isset($_SESSION['_token'])) {
$client->setAccessToken($_SESSION['_token']);
}
//get current user profile
$me = $client->users()->me();
echo $me->firstName.' '.$me->lastName.'<br>';
//get current user companies
$companies = $client->companies()->listCompanies();
foreach ($companies as $company) {
echo $company->name . "<br>";
}