Laravel 中的 cURL 请求
我正在努力在Laravel中提出此cURL请求
curl -d '{"key1":"value1", "key2":"value2"}' -H "Content-Type: application/json" -X GET http://my.domain.com/test.php
我一直在尝试这个:
$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();
但是我收到一个错误Class 'App\Http\Controllers\GuzzleHttp\RequestOptions' not found
有什么建议吗?
编辑
我需要从API获取响应,然后将其存储在数据库中...我该怎么做?:/$response