Skip to content

Companies

Max Kovpak edited this page Apr 15, 2020 · 2 revisions

List All Companies

require_once 'vendor/autoload.php';

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);

$client->authenticate([
    'grant_type' => 'password',
    'username'   => 'your email',
    'password'   => 'your password',
]);

$companies = $client->companies()->listCompanies();
foreach ($companies as $company) {
    echo $company->name . "<br>";
}

Get company id by slug

require_once 'vendor/autoload.php';

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);

$client->authenticate([
    'grant_type' => 'password',
    'username'   => 'your email',
    'password'   => 'your password',
]);

$companyId = $client->companies()->getCompanyIdBySlug('my-company-slug');
Clone this wiki locally