Files
2026-06-29 13:00:18 +06:00

48 lines
1.1 KiB
PHP

<?php
namespace App\Utility;
use Illuminate\Support\Facades\Http;
class Curl
{
private array $prepareData;
private static string $url;
private static array $header;
public function __construct($url,$header = ['Content-Type: application/json']){
static::$url = $url;
static::$header = $header;
}
private function prepareRequest($inputData){
return $inputData;
}
public function post($request){
$this->prepareData = $this->prepareRequest($request);
$response = Http::withHeaders(static::$header)
->post(
static::$url,
$this->prepareData
);
return json_decode((string) $response->getBody(), true);
}
public function get($request){
$this->prepareData = $this->prepareRequest($request);
$response = Http::withHeaders(static::$header)
->get(
static::$url,
$this->prepareData
);
return json_decode((string) $response->getBody(), true);
}
}