Forum Moderators: coopster

Message Too Old, No Replies

Curl for Admin and ssl

Trying to make curl work

         

bumpaw

4:20 am on Feb 8, 2004 (gmt 0)

10+ Year Member



I have a small project that allows a client user to input a database, and I would like to use curl to transfer the data with https. I've spent a few hours trying to learn to do this with no luck. From a Zend tutorial this works:

// FIND BOOKS ON PHP AND MYSQL ON AMAZON
$url = "http://www.amazon.com/exec/obidos/search-handle-form/002-5640957-2809605";
$ch = curl_init(); // initialize curl handle
curl_setopt($ch, CURLOPT_URL,$url); // set url to post to
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
curl_setopt($ch, CURLOPT_TIMEOUT, 3); // times out after 4s
curl_setopt($ch, CURLOPT_POST, 1); // set POST method
curl_setopt($ch, CURLOPT_POSTFIELDS, "url=index%3Dbooks&field-keywords=PHP+MYSQL"); // add POST fields
$result = curl_exec($ch); // run the whole process
curl_close($ch);
echo $result;

It works for me as it is, but if I change the URL to my site no luck. I guess that would be to easy.

dcrombie

12:32 pm on Feb 8, 2004 (gmt 0)



Starting with v7.10 you need to use the "insecure" option (unless you really know what you're doing with certificates):

system ("curl --insecure [some.secure-site.com...]

The "insecure" option doesn't exactly mean "insecure" but you'll have to read the man page or do some searching to find the difference. I'm sure the PHP library has something equivalent.

bumpaw

2:18 pm on Feb 8, 2004 (gmt 0)

10+ Year Member



Starting with v7.10 you need to use the "insecure" option (unless you really know what you're doing with certificates):

I know very little about certificates. I know that the host server has a shared certificate that you get when you access with [mydomain.com...]

The "insecure" option doesn't exactly mean "insecure" but you'll have to read the man page or do some searching to find the difference. I'm sure the PHP library has something equivalent.

I searched again, and still couldn't find something simple that tells me how to use curl with https. I know that the server has curl version 7.10.3, and that it should work because I have an oscommerce cart on the same server set up with Paypal IPN. I just don't know enough about it to do the PHP to make it work for this app. Maybe I could just call the page with https:// as my host tech suggests.

dcrombie

9:57 am on Feb 9, 2004 (gmt 0)



Looking at the PHP curl documentation [php.net] gives some clues;

curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);