Page 1 of 1

cURL not working - XAMPP on windows 10

PostPosted: 14. June 2016 10:11
by Dr_Sony
Hi all,

Sorry, if this is a basic question (i'm a damned newbie), but my cURL code seems to be giving me problem in windows 10 :roll: . I'm using XAMPP v3.2.2. cURL code works fine in windows 7, MAC OS and Linux. But, not in windows 10. I checked with microsoft too, but they don't have any solutions. Here is the code I'm using.

Code: Select all
curl_setopt_array($request, array(
                                CURLOPT_URL => 'https://www.sandbox.paypal.com/cgi-bin/webscr',
                                CURLOPT_POST => TRUE,
                                CURLOPT_POSTFIELDS => http_build_query(
                                  array(
                                    'cmd' => '_notify-synch',
                                    'tx' => $tx_token,
                                    'at' => $auth_token,
                                  )),
                                CURLOPT_RETURNTRANSFER => TRUE,
                                CURLOPT_HEADER => FALSE,
));

                              // Execute request and get response and status code
                              $res = curl_exec($request);
                              $status   = curl_getinfo($request, CURLINFO_HTTP_CODE);

                              // Close connection
                              curl_close($request);


I've checked similar posts on the forum, but none seem to give me the solution that works. Could you please help?

Thanks in advance for your help,
Dr_Sony

Re: cURL not working - XAMPP on windows 10

PostPosted: 14. June 2016 11:24
by Altrea
Hi,

"not working" is not a helpful error report.

And there is no XAMPP version 3.2.2. Please read this thread:
[Q&A] Insufficient debug information - base information

best wishes,
Altrea

Re: cURL not working - XAMPP on windows 10

PostPosted: 14. June 2016 11:59
by Nobbie
As Altrea altready said, "not working" is not a usefull message.

Anway, if that code works on different PCs and/or OS in your home, this might probably be an issue if a Windows firewall (or a similar tool you have installed, but mostly it is blocked by the default Windows firewall).

Re: cURL not working - XAMPP on windows 10

PostPosted: 14. June 2016 14:09
by gsmith
Anytime I see Curl and an https url I cringe a little because curl does not have a great certificate store. You would think it would accept an EV certificate from Symantec (which this PayPal's certificate is issued by) ... but no such luck it looks.

Code: Select all
C:\usr\local\curl>curl -I https://www.sandbox.paypal.com/
curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: http://curl.haxx.se/docs/sslcerts.html


Try adding the below to your script and see if it works then. If not there is a deeper problem.

CURLOPT_SSL_VERIFYPEER => FALSE,

Re: cURL not working - XAMPP on windows 10

PostPosted: 14. June 2016 18:39
by gsmith
This seems to be the problem. I gave you script a try feeding it garbage for the token and auth variables and echoing out the status then result returned.

the first attempt is without CURLOPT_SSL_VERIFYPEER, the second is with it and set to FALSE
Code: Select all
C:\temp>php test.php
0

C:\temp>php test.php
200
FAIL
Error: 4002

As can be seen the first attempt failed completely, the second worked (got the 200 status code) and the error is from paypal cause I fed it garbage.

Re: cURL not working - XAMPP on windows 10

PostPosted: 14. June 2016 19:04
by Nobbie
gsmith wrote:This seems to be the problem.


I did not check for that, but how can this be true:

I'm using XAMPP v3.2.2. cURL code works fine in windows 7, MAC OS and Linux. But, not in windows 10.


If you are right (what i do not doubt), this description is horribly wrong. It is NOT a question of Windows 10, why does the author tell us so? Strange.

Re: cURL not working - XAMPP on windows 10

PostPosted: 14. June 2016 21:26
by gsmith
Edit: I missed that and yes, if it works "as-is" in Windows 7 then this is strange. But then the poster may not have the exact php.ini settings in Win10 as in the Win7. php_curl may not be loaded tho IIRC it is in xampp out of the box.

php_curl did fail for the reason I posted so it is hard to imagine that this exact code worked on Win7.
I tested with both 7.0.2/Win7 and 5.6.10/Vista.

Re: cURL not working - XAMPP on windows 10

PostPosted: 15. June 2016 03:53
by Dr_Sony
Hello friends,

Thank you all, particularly gsmith, for your responses.

My apologies, I should have been more specific about 'not working'. Basically, we're trying to use cURL to generate the transaction result page, with details of transaction, after successful paypal payment. cURL helps us get these details from paypal. In all OS, other than Windows 10, transaction result page is successfully generated. In windows 10, it fails to run and displays no transaction parameters.

Altrea, sorry, I put up the version number of control panel. XAMPP version is 7.0.6. I think that's the latest one. We installed version 5.6.14 in windows 7, before we changed to windows 10 and it was formatted. It can be noted that we always used default settings, so there are no changes in php.ini settings other than the default setting differences between these two versions.

While installing new version of XAMPP, it did give us a warning "Because an activated User Account Control (UAC) on your system some functions of XAMPP are possibly restricted. With UAC, please avoid to install XAMPP to C:\program files (x86) (missing write permissions). Or, deactivate UAC with msconfig after this setup." We installed in a drive other than c:\.

Good news is, I've tried using gsmith's suggestion and it worked!!! Thanks! Why it didn't have any impact in v 5.6.14 in windows 7? I don't know. But, cURL works in windows 10 now. Thanks once again!

At this moment, we'll be cautious in using this only in development environment, not production.

Many thanks again
Dr_Sony