不再支持 PayPal IPN 和 fsockopen?
PayPal IPN and fsockopen no longer supported?
我的 PayPal IPN 脚本多年来一直有效。昨天它坏了,我们的网络服务器没有任何变化。当我收到 IPN 时,我的 PHP 脚本调用:
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value)
{
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
// post back to PayPal system to validate
$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 120);
if ($fp)
{
fputs ($fp, $header . $req);
while (!feof($fp))
{
...
}
}
}
PayPal 的文档现在讨论:
将响应消息发送回 PayPal:
https://ipnpb.sandbox.paypal.com/cgi-bin/webscr(对于沙盒 IPN)
https://ipnpb.paypal.com/cgi-bin/webscr(实时 IPN)
是否不再支持我的上述代码? PayPal 正在给我打电话,但似乎没有验证。
这是一个 HTTP/1.1 问题。
// 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: www.paypal.com\r\n";
$header .= "Connection: close\r\n\r\n";
...
if (strcmp(trim($result), "VERIFIED") == 0)
我的 PayPal IPN 脚本多年来一直有效。昨天它坏了,我们的网络服务器没有任何变化。当我收到 IPN 时,我的 PHP 脚本调用:
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value)
{
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
// post back to PayPal system to validate
$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 120);
if ($fp)
{
fputs ($fp, $header . $req);
while (!feof($fp))
{
...
}
}
}
PayPal 的文档现在讨论:
将响应消息发送回 PayPal:
https://ipnpb.sandbox.paypal.com/cgi-bin/webscr(对于沙盒 IPN)
https://ipnpb.paypal.com/cgi-bin/webscr(实时 IPN)
是否不再支持我的上述代码? PayPal 正在给我打电话,但似乎没有验证。
这是一个 HTTP/1.1 问题。
// 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: www.paypal.com\r\n";
$header .= "Connection: close\r\n\r\n";
...
if (strcmp(trim($result), "VERIFIED") == 0)