Question: I am struggling to make this cURL request in Laravel

```
curl -d '{"key1":"value1", "key2":"value2"}' -H "Content-Type: application/json"   -X GET http://my.domain.com/test.php

```

I've been trying this:

```
$endpoint = "http://my.domain.com/test.php";

$client = new \GuzzleHttp\Client();

$response = $client->post($endpoint, [
                GuzzleHttp\RequestOptions::JSON => ['key1' => $id, 'key2' => 'Test'],
            ]);

$statusCode = $response->getStatusCode();

```

But I am getting an error `Class 'App\Http\Controllers\GuzzleHttp\RequestOptions' not found`

Any suggestions?

**EDIT**

I need to get the response from API in `$response` and then store it in DB... How can I do this? :/

Answer: 
You can still use the native cURL in PHP if you have trouble using guzzlehttp:

**Native Php way** 

```
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "SOME_URL_HERE".$method_request);
// SSL important
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$output = curl_exec($ch);
curl_close($ch);

$this - > response['response'] = json_decode($output);

```

Sometimes this solution still better and simplier than using the library attached in the Laravel framework. But still your choice since you hold the development of your project.
I believe, since Laravel 7, Laravel comes with a HTTP Client which is a wrapper for Guzzle HTTP. So now something like this would have worked.

```php
use Illuminate\Support\Facades\Http;

$response = Http::get('http://my.domain.com/test.php', [
    'key1' => $id, 
    'key2' => 'Test',
]);

if ($response->failed()) {
   // return failure
} else {
   // return success
}

```

it's amazing and much more cleaner, easier to test, [here's the documentation](https://laravel.com/docs/8.x/http-client)