不再支持 PayPal IPN 和 fsockopen?
Posted
技术标签:
【中文标题】不再支持 PayPal IPN 和 fsockopen?【英文标题】:PayPal IPN and fsockopen no longer supported? 【发布时间】:2019-02-13 19:12:24 【问题描述】:多年来,我的 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 正在给我打电话,但似乎没有验证。
【问题讨论】:
【参考方案1】:这是一个 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 和 fsockopen?的主要内容,如果未能解决你的问题,请参考以下文章
我的服务器突然不再接收来自 Paypal 的 IPN 请求,工作了多年
Paypal IPN - 无法打开套接字 - OVH mutu