add auto update feature

This commit is contained in:
jayvirsinh_gohil
2019-11-12 18:44:49 +05:30
parent 81f34b8912
commit 1b28b082d2
8 changed files with 254 additions and 2 deletions

35
app/Space/SiteApi.php Normal file
View File

@ -0,0 +1,35 @@
<?php
namespace Laraspace\Space;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
trait SiteApi
{
protected static function getRemote($url, $data = array())
{
$base = 'https://codeload.github.com/';
$client = new Client(['verify' => false, 'base_uri' => $base]);
$headers['headers'] = array(
'Accept' => 'application/json',
'Referer' => url('/'),
'crater' => getFullVersion()
);
$data['http_errors'] = false;
$data = array_merge($data, $headers);
try {
$result = $client->get($url, $data);
} catch (RequestException $e) {
$result = $e;
}
return $result;
}
}