Untitled
Anonymous
php
02/15/2021 11:57 AM
868 B
24
Indexable
<?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 protected]');
$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";
Editor is loading...