CURL request task

I am trying to verify pdt paypal information.

I created my layout form and submitted it. IT worked and also returned information.

I tried the same thing I made a curl request. But my request request is returned to me.

my breadboard form:

<form method="post" action="https://sandbox.paypal.com/cgi-bin/webscr"> <input type="hidden" name="cmd" value="_notify-synch"/> <input type="hidden" name="at" value="-----"/> <input type="hidden" name="tx" value="-----"/> <input type="submit" value="Test"/> </form> 

My CURL REQ Code:

 $arrData = array( 'tx' => '----', 'cmd' => '_notify-synch', 'at' => '-----' ); $ch = curl_init( 'https://sandbox.paypal.com/cgi-bin/webscr' ); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1) ; curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $arrData); $strCurlResult = curl_exec($ch); curl_close( $ch ); return $strCurlResult; 

EDIT:

Tracking tracking error ON, I found the following message:

SSL: certificate subject name 'www.sandbox.paypal.com' does not match target host name 'sandbox.paypal.com'

+7
source share
5 answers

Edit: $ ch = curl_init ('https://sandbox.paypal.com/cgi-bin/webscr');
To: $ ch = curl_init ('https://www.sandbox.paypal.com/cgi-bin/webscr');

Reason: The certificate for www.sandbox.paypal.com is not valid for sandbox.paypal.com.
Similarly, make the same change in your action form.

+8
source

In fact, you can simply turn off the host check. In some versions of PHP / cURL, simply disabling PEER is not enough:

 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); 

From the docs:

CURLOPT_SSL_VERIFYHOST: 1 check for a common name in the SSL partner certificate. 2 to check for a common name and also make sure that it matches the specified host name. In production environments, the value of this option should be stored in 2 (the default value).

+21
source

You need to specify cURL to not check the SSL certificate. This can be done by setting the cURL option:

 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 

Further information here:

http://php.net/manual/en/function.curl-setopt.php

+6
source

curl_setopt ($ ch, CURLOPT_SSL_VERIFYPEER, 0);

although the above work is not recommended.

as robert said

Change:

$ ch = curl_init ('https://sandbox.paypal.com/cgi-bin/webscr');

To:

$ ch = curl_init ('https://www.sandbox.paypal.com/cgi-bin/webscr');

+2
source

Send it as a string:

 $arrData = array( 'tx' => '----', 'cmd' => '_notify-synch', 'at' => '-----' ); $fields_string = ""; foreach($arrData as $key=>$value) $fields_string .= $key.'='.$value.'&'; rtrim($fields_string,'&'); $ch = curl_init( 'https://sandbox.paypal.com/cgi-bin/webscr' ); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1) ; curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); $strCurlResult = curl_exec($ch); curl_close( $ch ); return $strCurlResult; 
0
source

All Articles