mirror of
				https://github.com/crater-invoice/crater.git
				synced 2025-11-03 22:13:18 -05:00 
			
		
		
		
	
		
			
				
	
	
		
			38 lines
		
	
	
		
			862 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
		
			862 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace Crater\Space;
 | 
						|
 | 
						|
use GuzzleHttp\Client;
 | 
						|
use GuzzleHttp\Exception\RequestException;
 | 
						|
use Crater\Setting;
 | 
						|
 | 
						|
// Implementation taken from Akaunting - https://github.com/akaunting/akaunting
 | 
						|
trait SiteApi
 | 
						|
{
 | 
						|
 | 
						|
    protected static function getRemote($url, $data = array())
 | 
						|
    {
 | 
						|
        $base = 'https://craterapp.com/';
 | 
						|
 | 
						|
        $client = new Client(['verify' => false, 'base_uri' => $base]);
 | 
						|
 | 
						|
        $headers['headers'] = array(
 | 
						|
            'Accept'        => 'application/json',
 | 
						|
            'Referer'       => url('/'),
 | 
						|
            'crater'        => Setting::getSetting('version')
 | 
						|
        );
 | 
						|
 | 
						|
        $data['http_errors'] = false;
 | 
						|
 | 
						|
        $data = array_merge($data, $headers);
 | 
						|
 | 
						|
        try {
 | 
						|
            $result = $client->get($url, $data);
 | 
						|
        } catch (RequestException $e) {
 | 
						|
            $result = $e;
 | 
						|
        }
 | 
						|
 | 
						|
        return $result;
 | 
						|
    }
 | 
						|
}
 |