Untitled

mail@pastecode.io avatar
unknown
php
3 years ago
649 B
4
Indexable
Never
<?php

use MidrubApps\OpenApi\Api\AuthApi;
use MidrubApps\OpenApi\Model;

require_once(__DIR__ . '/bootstrap.php');


$api = new AuthApi();

$api->getConfig()->setHost('https://stage.postoplan.app/api/v1');
$api->getConfig()->setApiKey('api-key', '<api key>');

$req = new Model\AuthRequest;
$req->setLogin('email@yahoo.com');
$req->setPassword('password');
$response = $api->authLogin($req);
if($response->getOk()) {
    echo "Logged in\n";
} else {
    var_export($response->getErrors());
    return;
}
$api->getConfig()->setApiKey('api-token', $response->getToken());
$response = $api->authGetUser();
echo "Hello, {$response->getUsername()}!\n";