1 | <?php |
---|
2 | require_once('../../../../plugins/lib/autoload.php'); |
---|
3 | |
---|
4 | $options = [ |
---|
5 | 'headers' => [ |
---|
6 | 'User-Agent' => 'Ready_/', |
---|
7 | 'Accept' => '*/*' |
---|
8 | ], |
---|
9 | 'form_params' => [ |
---|
10 | 'edok_login' => 'q', |
---|
11 | 'edok_password' => 'a', |
---|
12 | 'edok_entity' => 'q', |
---|
13 | ], |
---|
14 | 'http_errors' => TRUE, |
---|
15 | ]; |
---|
16 | |
---|
17 | $client = new GuzzleHttp\Client([ |
---|
18 | 'base_uri' => 'http://localhost/ready/api.php/', |
---|
19 | 'verify' => FALSE, |
---|
20 | ]); |
---|
21 | |
---|
22 | try { |
---|
23 | $response = $client->request('POST', 'REST/login/', $options); |
---|
24 | } catch (Exception $exception) { |
---|
25 | print_r($exception->getMessage()); |
---|
26 | } |
---|
27 | |
---|
28 | if ($response->getStatusCode() == 200) { |
---|
29 | print_r(json_decode($response->getBody())); |
---|
30 | } else { |
---|
31 | echo 'fail'; |
---|
32 | } |
---|