public function post($full_url, array $multi_parts = [], array $headers = [])
{
$options = ['debug' => GUZZLE_DEBUG];
// Grab the client's handler instance.
$clientHandler = $this->client->getConfig('handler');
// Create a middleware that echoes parts of the request.
$tapMiddleware = Middleware::tap(function ($request) {
echo $request->getHeader('Content-Type');
// application/json
echo $request->getBody();
// {"foo":"bar"}
});
//$options['handler'] = $tapMiddleware($clientHandler);
$multi_part_vars = array();
foreach ($multi_parts as $name => $data) {
if (is_array($data)) {
$data['name'] = $name;
} else {
$data = ['name' => $name, 'contents' => $data];
}
$multi_part_vars[] = $data;
}
$options['multipart'] = $multi_part_vars;
//$options['headers'] = ['Referer' => $full_url];
if (!empty($headers)) {
$options['headers'] = $headers;
}
$this->response = $this->client->post($full_url, $options);
return $this;
}