JSON - Convert code from JQuery to PHP <p>i'm trying to convert a code from JQuery to PHP to do a json POST request to remote server.</p> <p>My Jquery code is:</p> <pre><code>$( document ).ready(function() { $('#button').click( function() { $.ajax({ method: "POST", url: "http://http://www.fedex.com/trackingCal/track", data: { action: "trackpackages", format: "json", locale: "it_IT", version: "1", data: '{"TrackPackagesRequest":{"appType":"WTRK","uniqueKey":"","processingParameters":{},"trackingInfoList":[{"trackNumberInfo":{"trackingNumber":"780909642310","trackingQualifier":"","trackingCarrier":""}}]}}' } }) .done(function( msg ) { console.log( msg ); }); } ) }); </code></pre> <p>I would like to do same POST request call from PHP, but i can not.</p> <p>My PHP code is:</p> <pre><code>$data = array("action" =&gt; "trackpackages", "data" =&gt; array ('TrackPackagesRequest' =&gt; array('appType' =&gt; 'WTRK', 'uniqueKey' =&gt; '', 'processingParameters' =&gt; '{}', 'trackingInfoList' =&gt; array(array('trackNumberInfo' =&gt; array('trackingNumber' =&gt; '780909642310', 'trackingQualifier' =&gt; '', 'trackingCarrier' =&gt; ''))))), 'format' =&gt; 'json', 'locale' =&gt; 'it_IT', 'version' =&gt; '1'); $data_string = json_encode($data); $ch = curl_init('http://www.fedex.com/trackingCal/track'); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($data_string)) ); $result = curl_exec($ch); echo $result; </code></pre> <p>Remote server is not responding properly and seems not receive the data properly encoded. Can someone help me to solve this problem?</p> <p>Thank You!</p>