PHP code example of brainfab / moygrafik_php_sdk
1. Go to this page and download the library: Download brainfab/moygrafik_php_sdk library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
brainfab / moygrafik_php_sdk example snippets
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']);
}
$companies = $client->companies()->listCompanies();
foreach ($companies as $company) {
echo $company->name . "<br>";
}