Debugging PHP cURL

Web hosting discussion, programming, and shared and dedicated servers.
4 posts Page 1 of 1
by sdogjm » Thu Aug 09, 2012 6:15 pm
I am trying to get a WordPress plugin working on a client site. Among other things, the plugin sends a request to PayPal. The PHP script uses cURL to handle this request. The code excerpt is:

Code: Select all

	// Set the curl parameters.
	$ch = curl_init();
	
	//re: this bug http://curl.haxx.se/mail/lib-2010-06/0169.html
	curl_setopt($ch, CURLOPT_SSLVERSION, 3);
		
	curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
	curl_setopt($ch, CURLOPT_VERBOSE, 1);

	// Turn off the server and peer verification (TrustManager Concept).
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);

	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_POST, 1);

	// Set the API operation, version, and API signature in the request.
	$nvpreq = "METHOD=$methodName_&VERSION=$version&PWD=$API_Password&USER=$API_UserName&SIGNATURE=$API_Signature&$nvpStr_";
	
	// Set the request as a POST FIELD for curl.
	curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);
	
	// Get response from the server.
	$httpResponse = curl_exec($ch);

It crashes when it does the curl_exec statement. I get a 500 Internal Server Error back.

I have played with the options, but nothing I do changes the results. I'm beginning to think that I have a configuration or permissions problem of some kind. The error message suggest that more information about this error may be available in the server error log. I'm not sure what log this is or where I might find it.

I've spent a lot of time trying to figure this out and not getting anywhere. Any insights or suggestions would be most welcome.

Thanks in advance... John
by williamt » Mon Aug 13, 2012 11:15 am
Hi John,

Might I suggest running a test via the command line? That way you should see all output.
You probably also want to make sure your using php 5.3 as explained here:
https://wiki.sonic.net/wiki/Php5
Sr. Systems Administrator @ sonic.net
by sdogjm » Sun Aug 19, 2012 11:31 am
I finally got back to this project. Thank you, WilliamT, for the suggestion to specify php 5.3. That seems to have taken care of this problem and gotten me beyond the 500 Internal Server error. I had been stuck there for a while.

John
by williamt » Mon Aug 20, 2012 8:56 am
Glad to hear it.
Sr. Systems Administrator @ sonic.net
4 posts Page 1 of 1

Who is online

In total there are 23 users online :: 0 registered, 0 hidden and 23 guests (based on users active over the past 5 minutes)
Most users ever online was 999 on Mon May 10, 2021 1:02 am

Users browsing this forum: No registered users and 23 guests