How to use Guzzle?

It is necessary to make a POST request with JSON data to the website. Do this:
$this->client = new GuzzleHttp\Client(['base_uri' => AC_URL]);
...
public function send($data) {
 $response = $this->client->request('POST', AC_URL, $data);
 return (array)json_decode($response->getBody()->getContents());
}

What's wrong? In the $data - array with data. Maybe somewhere else to specify what the data type is json? Or convert most data in json? How to make? Just please no references to the docks. They all have been dug. A lot of information, but for some reason the examples is a POST request in JSON and that is very little. Just tell me what my error is?
July 5th 19 at 00:04
1 answer
July 5th 19 at 00:07
Solution
$this->client = new GuzzleHttp\Client(['base_uri' => AC_URL]);
...
public function send($data) {
 $response = $this->client->request('POST', AC_URL, ['json' => $data]);
 return (array)json_decode($response->getBody()->getContents());
}

Find more questions by tags PHP