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: 
Give the query-option from Guzzle a try:

```
$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,
]]);

// url will be: http://my.domain.com/test.php?key1=5&key2=ABC;

$statusCode = $response->getStatusCode();
$content = $response->getBody();

// or when your server returns json
// $content = json_decode($response->getBody(), true);

```

I use this option to build my get-requests with guzzle. In combination with json\_decode($json\_values, true) you can transform json to a php-array.
Using Laravel, you can write something like this in your routes file if you are using WP and you are feeling adventurous and don't want to use guzzle or Laravel cURL package.

```php
Route::get('/curl',function() {
    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, 'https://example.net/wp-login.php');

    // save cookies to 'public/cookie.txt' you can change this later.
    curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');

    curl_setopt($ch, CURLOPT_POSTFIELDS, ['log'=>'<name>','pwd'=>'<pass>']);

    curl_exec($ch);

    // supply cookie with request
    curl_setopt($ch, CURLOPT_COOKIE, 'cookie.txt');

    // the url you would like to visit
    curl_setopt($ch, CURLOPT_URL, 'https://example.net/profile/');

    $content = curl_exec($ch);

    curl_close($ch);

    // webpage will be displayed in your browser
    return;
});

```