-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexecute.php
More file actions
43 lines (36 loc) · 1.26 KB
/
execute.php
File metadata and controls
43 lines (36 loc) · 1.26 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
43
<?php
namespace Example;
use Fortifi\Api\Core\Connections\Requests2Connection;
use Fortifi\Api\Core\OAuth\Grants\ServiceAccountGrant;
use Fortifi\Api\V1\Definitions\FortifiApiDefinition;
use Fortifi\Api\V1\Endpoints\FortifiApi;
require_once 'vendor/autoload.php';
// These details are available within the service accounts page:
// https://[orgname].fortifi.cloud/settings/organisation/service-accounts
// By clicking the [view] button on your desired service account
//TODO: Replace the following details with your own account details
const ORG_FID = 'ORG:XY:1234:abcde'; //Organisation FID
const API_USER = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const API_KEY = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$connection = new Requests2Connection();
$connection->setOrganisationFid(ORG_FID);
$api = new FortifiApi();
$def = $api->getApiDefinition();
if($def instanceof FortifiApiDefinition)
{
$def->setHost('api.fortifi.me');
}
$api->setConnection($connection)->setAccessGrant(new ServiceAccountGrant(API_USER, API_KEY));
try
{
$result = $api->brands()->all();
var_export([
$result->wasSuccessful() ? "SUCCESS" : "FAILED",
$result->getRawResult()->getStatusCode(),
$result->getDecodedResponse(),
]);
}
catch(\Exception $e)
{
var_export([$e->getCode(), $e->getMessage()]);
}