v2 first commit
This commit is contained in:
@ -8,26 +8,26 @@ use GuzzleHttp\Exception\RequestException;
|
||||
trait SiteApi
|
||||
{
|
||||
|
||||
protected static function getRemote($url, $data = array())
|
||||
protected static function getRemote($path, $method = 'GET', $data = [])
|
||||
{
|
||||
$base = 'https://akaunting.com/api/';
|
||||
$base = 'https://api.akaunting.com/';
|
||||
|
||||
$client = new Client(['verify' => false, 'base_uri' => $base]);
|
||||
|
||||
$headers['headers'] = array(
|
||||
'Authorization' => 'Bearer ' . setting('general.api_token'),
|
||||
$headers['headers'] = [
|
||||
'Authorization' => 'Bearer ' . setting('apps.api_key'),
|
||||
'Accept' => 'application/json',
|
||||
'Referer' => url('/'),
|
||||
'Akaunting' => version('short'),
|
||||
'Language' => language()->getShortCode()
|
||||
);
|
||||
];
|
||||
|
||||
$data['http_errors'] = false;
|
||||
|
||||
$data = array_merge($data, $headers);
|
||||
|
||||
try {
|
||||
$result = $client->get($url, $data);
|
||||
$result = $client->request($method, $path, $data);
|
||||
} catch (RequestException $e) {
|
||||
$result = $e;
|
||||
}
|
||||
|
Reference in New Issue
Block a user