I need to connect to an API with my Laravel 5.1 project so I write function to test:
public function testDng() {
$client = new GuzzleHttp\Client(['verify' => false ]);
try {
$res = $client->post('https://api.example.com/api/authenticate', [
'form_params' => [
'email' => 'john@example.com',
'password' => 'asdasd'
]
]);
return $res;
}
catch (GuzzleHttp\Exception\ClientException $e) {
$response = $e->getResponse();
$result = json_decode($response->getBody()->getContents());
return response()->json(['data' => $result]);
}
}
The result of this function is:
{"data":null}
but when I try this API in Postman app everything is fine and I get token:
So something is wrong with my function ... What caused the problem and why I cant get token?