<?php
require_once('../../../../plugins/lib/autoload.php');

$options = [
    'headers' => [
        'User-Agent' => 'Ready_/',
        'Accept' => '*/*'
    ],
    'form_params' => [
        'edok_login'    => 'q',
        'edok_password' => 'a',
        'edok_entity'   => 'q',
    ],
    'http_errors' => TRUE,
];

$client = new GuzzleHttp\Client([
    'base_uri' => 'http://localhost/ready/api.php/',
    'verify' => FALSE,
]);

try {
    $response = $client->request('POST', 'REST/login/', $options);
} catch (Exception $exception) {
    print_r($exception->getMessage());
}

if ($response->getStatusCode() == 200) {
    print_r(json_decode($response->getBody()));
} else {
    echo 'fail';
}