����JFIF��x�x����'
Server IP : 78.140.185.180 / Your IP : 18.218.226.136 Web Server : LiteSpeed System : Linux cpanel13.v.fozzy.com 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64 User : builderbox ( 1072) PHP Version : 7.3.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/builderbox/www/common/Core/ |
Upload File : |
<?php namespace Common\Core; use Common\Settings\Settings; use GuzzleHttp\Client; class HttpClient { /** * @var Client */ private $client; /** * @param array $params */ public function __construct($params = []) { if ( ! isset($params['exceptions'])) $params['exceptions'] = false; if ( ! isset($params['timeout'])) $params['timeout'] = 2; $defaultVerify = (bool) app(Settings::class)->get('https.enable_cert_verification', true); if ( ! isset($params['verify'])) $params['verify'] = $defaultVerify; $this->client = new Client($params); } /** * @param string $url * @param array $params * @return array|string */ public function get(string $url, array $params = []) { $r = $this->client->get($url, $params); if ($r->getStatusCode() === 429 && $r->hasHeader('Retry-After')) { $seconds = $r->getHeader('Retry-After') ? $r->getHeader('Retry-After') : 5; sleep((int) $seconds); $r = $this->get($url); } $contents = is_string($r) ? $r : $r->getBody()->getContents(); $json = json_decode($contents, true); return $json ? $json : $contents; } /** * @param string $url * @param array $params * @return array */ public function post($url, $params = []) { $r = $this->client->post($url, $params); if ($r->getStatusCode() === 429 && $r->hasHeader('Retry-After')) { $seconds = $r->getHeader('Retry-After') ? $r->getHeader('Retry-After') : 5; sleep($seconds); $r = $this->get($url); } $contents = $r->getBody()->getContents(); $json = json_decode($contents, true); return $json ? $json : $contents; } }