cURL not working - XAMPP on windows 10

Problems with the Windows version of XAMPP, questions, comments, and anything related.

cURL not working - XAMPP on windows 10

Postby Dr_Sony » 14. June 2016 10:11

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
Dr_Sony
 
Posts: 2
Joined: 14. June 2016 10:01
XAMPP version: 3.2.2
Operating System: windows 10

Re: cURL not working - XAMPP on windows 10

Postby Altrea » 14. June 2016 11:24

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
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11935
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: cURL not working - XAMPP on windows 10

Postby Nobbie » 14. June 2016 11:59

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).
Nobbie
 
Posts: 13183
Joined: 09. March 2008 13:04

Re: cURL not working - XAMPP on windows 10

Postby gsmith » 14. June 2016 14:09

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,
gsmith
 
Posts: 278
Joined: 29. November 2013 18:04
Location: San Diego
XAMPP version: 0.0.0
Operating System: Win 10/2012R VS 14,15,16

Re: cURL not working - XAMPP on windows 10

Postby gsmith » 14. June 2016 18:39

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.
gsmith
 
Posts: 278
Joined: 29. November 2013 18:04
Location: San Diego
XAMPP version: 0.0.0
Operating System: Win 10/2012R VS 14,15,16

Re: cURL not working - XAMPP on windows 10

Postby Nobbie » 14. June 2016 19:04

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.
Nobbie
 
Posts: 13183
Joined: 09. March 2008 13:04

Re: cURL not working - XAMPP on windows 10

Postby gsmith » 14. June 2016 21:26

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.
gsmith
 
Posts: 278
Joined: 29. November 2013 18:04
Location: San Diego
XAMPP version: 0.0.0
Operating System: Win 10/2012R VS 14,15,16

Re: cURL not working - XAMPP on windows 10

Postby Dr_Sony » 15. June 2016 03:53

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
Dr_Sony
 
Posts: 2
Joined: 14. June 2016 10:01
XAMPP version: 3.2.2
Operating System: windows 10


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 144 guests