Question

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

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-http://162.243.88.70/info.php. 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?


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Kamal Nasser
DigitalOcean Employee
DigitalOcean Employee badge
February 4, 2014
Accepted Answer

Seems like a php problem. Try adding <code>error_reporting(-1);ini_set(‘display_errors’, 1);</code> at the top of your file, does that make it output any errors? <br> <br>Do you have the curl extension installed? <pre>sudo apt-get install php5-curl</pre>

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… <br> <br>try to update it then see whether the error persist or not…

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more