Problem with Curl or Json (Debian 7.2, PHP 5.5 e etc)

February 3, 2014 5.3k views
Hi, I have a site that is running Opencart and makes payment for the Paybras, testing locally worked 100%, but in Digital Ocean Json return of payment is always null. The Firewall is empty and already installed Curl and Json, etc- The code used is as follows: $ch = curl_init ($url); $data _ string = json_encode ($data); 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)) ); $resultado = curl_exec ($ch); curl_close ($ch); return $resultado; Log data: It returns the following steps: 2/3/2014 13:44:04-Paybras = 1 validation 2/3/2014 13:44:04-Calling the Curl Paybras 2/3/2014 13:44:05-Return the Json (wave) 2/3/2014 13:44:05-if non-success Being the return of Json (Curl) was to return a variable of success, but as the return is empty does not return anything. The Curl is running normal with other mode of payment, so that's not a problem with him. The function is called by Ajax Post type and Json data and before you go to the Log data is converted into PHP with json_decode and only after I test the Log. Does anyone have any idea what can be the problem?
2 Answers
kamaln7 MOD February 4, 2014
Accepted Answer
Seems like a php problem. Try adding error_reporting(-1);ini_set('display_errors', 1); at the top of your file, does that make it output any errors?

Do you have the curl extension installed?
sudo apt-get install php5-curl
I vaguely remember whether json has some issue with php5.x.x because just today I had to upgrade my php to the latest versions php5.5.8 to avoid a lot of issues including json...

try to update it then see whether the error persist or not..
Have another answer? Share your knowledge.