A
A
Andrey Plax2014-09-09 13:08:26
linux
Andrey Plax, 2014-09-09 13:08:26

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); 
?>

From the development Vin-machine - everything is OK.
From the production server, the sent string is additionally "escaped" with quotes, which leads to the non-acceptance of the string by the remote server.
If anyone knows what's going on, please help.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Lerg, 2014-09-09
@Hereigo

en2.php.net/manual/en/security.magicquotes.php

A
Andrey Plax, 2014-09-09
@Hereigo

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 question

Ask a Question

731 491 924 answers to any question