I'm working on a project that need to call a API to get json response, but the Guzzle client auth is not working. It always redirect to the login page. "nasa" is the database. Here's my code:
<?php
require_once '../composer/vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client([
'base_url' => ['http://fedview.bfountain.com/{datasource}/', ['datasource' => 'nasa']]]);
$response = $client->get('service/sbapp/goalByAgency', ['auth' => ['username', 'password']]);
echo $response->getBody();
?>
I tried:
$response = $client->get('login.do?uname=username&passcode=password');
It can log in successfully.
Can anyone help me on this? (I'm using Guzzle 5) THX!