Answer the question
In order to leave comments, you need to log in
Why extra characters are added when sending JSON via CURL after Deploy from Win to Ubuntu?
1. Development on a Windows machine (Apache 2.2.2 + PHP Version 5.3.28 - Windows 8.1 x64)
2. Production on an Ubuntu server (Apache 2.2.2 + PHP Version 5.3.10 - Ubuntu Server 12)
3. Access to a remote there is no server - partner.
4. Data is transmitted via CURL + HTTPS.
Run the code below:
<?php
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://remoteServer/remotePath');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($curl, CURLOPT_CAINFO, '/etc/ssl/certs/cert.crt');
$data_string = "{\"system\":\"abc\",\"fields\":{\"agreement_Number\":\"123\",\"inn\":\"1234567890\",\"passport_seria\":\"AB123456\",\"amount\":\"123.85\"}}";
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string)));
curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);
curl_exec($curl);
?>
Answer the question
In order to leave comments, you need to log in
Finally, we managed to contact the technical support of the "remote server" and they solved the problem with cutting off extra quotes on their part. Unfortunately, I did not have time to check your advice. Now to check, it is no longer possible. But judging by the information we read, from your link, and also quite useful, we will assume that this was the decision.
Thank you.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question