curl laravel 7 code example
Example 1: laravel curl request
$client = new GuzzleHttp\Client;
$response = $client->get('https://api.example.com/api/AvailabilitySearch', [
'headers' => [
'Authorization' => 'Bearer YOUR_TOKEN_HERE',
],
'form_params' => [
'VisitDate' => '2017-05-08',
'PartySize' => '2',
'ChannelCode' => 'ONLINE',
],
]);
$response = json_decode($response->getBody(), true);
$endpoint = "http://my.domain.com/test.php";
$client = new \GuzzleHttp\Client();
$id = 5;
$value = "ABC";
$response = $client->request('GET', $endpoint, ['query' => [
'key1' => $id,
'key2' => $value,
]]);
$statusCode = $response->getStatusCode();
$content = $response->getBody();
Example 2: laravel http client
composer require guzzlehttp/guzzle
Example 3: laravel http client
use Illuminate\Support\Facades\Http;
$response = Http::get('http://test.com');