Help Article

How do I modify my IPN PHP listener to support HTTP1.1?

Important: PayPal has required the use of HTTP 1.1 since October 2013.

To modify your IPN PHP listener to support HTTP1.1, you need to include the "Host" and "Connection" headers in the IPN postback script. The following example shows how:


// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.1\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Host:\r\n";
$header .= "Connection: close\r\n\r\n";
Note: For further compatibility, your PHP script should also trim the IPN validation response. Modify your script from this:
if (strcmp ($res, "VERIFIED") == 0) {
else if (strcmp ($res, "INVALID") == 0) {
To this:
if (strcmp (trim($res), "VERIFIED") == 0) {
else if (strcmp (trim($res), "INVALID") == 0) {
In PHP, check that the last line of your header includes double end-of-line markers: \r\n\r\n as in the next example:
$header .="Connection: close\r\n\r\n";
In PHP, open the socket connection to the same host declared in the header. Your header is declaring the host as:
$header .="Host:\r\n";
You should open the connection to the same host:
$fp = fsockopen ('ssl://', 443, $errno, $errstr, 30);

Note: For new IPN integrations, we recommend these updated samples.
We’re sorry, the page you’re looking for is no longer available. Please try your search again in our Help Center if you have a question or want to contact us.