I am Trying to convert an existing phpCurl request to latest guzzle and not getting anywhere fast.
This is the current request.
$curl_opts = array(
CURLOPT_HEADER => false,
CURLOPT_HTTPHEADER => array('Content-Type: text/json', 'Content-length: '.strlen($json)),
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $json,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => 'https://the-domainservice.php',
CURLOPT_VERBOSE => false,
CURLOPT_SSLCERT => '/path/to/file.pem',
CURLOPT_SSLCERTTYPE => 'pem',
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1
);
$curl = curl_init();
curl_setopt_array($curl, $curl_opts);
$response = curl_exec($curl);
For Guzzle I have tried so many ways but here are a couple of example.
$response = $this->client->post('https://the-domainservice.php', [
'body' => $postData,
'cert' => '/path/to/file.pem',
'config' => [
'curl' => [
CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_RETURNTRANSFER => true
]
]
]
);
And more verbose of
$request = $this->client->createRequest('POST', 'https://the-domainservice.php', [
'cert' => '/path/to/file.pem',
'verify' => false,
'headers' => [
'Content-Type' => 'text/json',
'Content-length' => strlen(json_encode($postData))
]
]);
$postBody = $request->getBody();
foreach ($postData as $key => $value) {
$postBody->setField($key, $value);
}
$response = $this->client->send($request);
For my guzzle requests I am just getting
GuzzleHttp\Exception\ServerException: Server error response [url] https://the-domainservice.php [status code] 500 [reason phrase] Internal Service Error
Really hope someone can advise.