mirror of
				https://github.com/crater-invoice/crater.git
				synced 2025-10-30 21:21:09 -04:00 
			
		
		
		
	
		
			
				
	
	
		
			37 lines
		
	
	
		
			790 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			790 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace Laraspace\Space;
 | |
| 
 | |
| use GuzzleHttp\Client;
 | |
| use GuzzleHttp\Exception\RequestException;
 | |
| use Laraspace\Setting;
 | |
| 
 | |
| trait SiteApi
 | |
| {
 | |
| 
 | |
|     protected static function getRemote($url, $data = array())
 | |
|     {
 | |
|         $base = 'http://crater-main.test/';
 | |
| 
 | |
|         $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;
 | |
|     }
 | |
| }
 |