0

Hi Everyone - I keep getting the following error messages in my log file

[19-Jan-2017 22:16:46 UTC] PHP Notice: Use of undefined constant CURLOPT_httpsHEADER - assumed 'CURLOPT_httpsHEADER'
on line 22
[19-Jan-2017 22:16:46 UTC] PHP Warning: curl_setopt() expects parameter 2 to be long, string given
on line 22

This is the top of my IPN listener file -

// Check to see there are posted variables coming into the script
if ($_SERVER['REQUEST_METHOD'] != "POST") die ("No Post Variables");
// Initialize the $req variable and add CMD key value pair
$req = 'cmd=_notify-validate';
// Read the post from PayPal
foreach ($_POST as $key => $value) {
    $value = urlencode(stripslashes($value));
    $req .= "&$key=$value";
}
// Now Post all of that back to PayPal's server using curl, and validate everything with PayPal
// We will use CURL instead of PHP for this for a more universally operable script (fsockopen has issues on some environments)
//$url = "https://www.sandbox.paypal.com/cgi-bin/webscr";
//$url = "https://www.paypal.com/cgi-bin/webscr";
$url = "https://ipnpb.paypal.com/cgi-bin/webscr";
$curl_result=$curl_err='';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_httpsHEADER, array("Content-Type: application/x-www-form-urlencoded", "Content-Length: " . strlen($req)));
curl_setopt($ch, CURLOPT_HEADER , 0);   
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 2);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$curl_result = @curl_exec($ch);
$curl_err = curl_error($ch);
curl_close($ch);

Can someone help me & understand how to fix the problem

2
Contributors
6
Replies
27
Views
7 Months
Discussion Span
Last Post by Dani
2

Umm ... I don't think CURLOPT_HTTPSHEADER is a known cURL variable. Try doing something like this instead:

curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/x-www-form-urlencoded',
    'Content-Length: ' . strlen($req),
));
0

OK thanks - I will look into this now - test and let you know how it goes, thanks for your quick reply

0

Hi - Still getting the same error when removing the (s) from https: and using single quotes ( ' )

1

Are you sure you're getting the same error message?? What version of PHP are you using??

0

Hi, Sorry, I misread the code above and I entered the http in lowercase - Not upper case.
All working now -Thanks Dani

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.