PayPal Sandbox IPN不再响应



我正在用贝宝(PayPal)沙盒测试我的php脚本,该脚本可与www.paypal.com一起使用,但不能使用www.sandbox.paypal.com。我最近收到了PayPal的一封电子邮件,要求使用HTTP 1.1协议而不是1.0,因此我已经完成了此操作,并且按照指定的标题中使用Connection: close,但是IPN URL挂起。当我使用www.paypal.com尝试时,没有悬挂。

PayPal在他们的第二封电子邮件

中做到了这一点

这是我们2012年9月6日发送的公告的后续行动。 引起我们注意的是,有些商人正在遇到问题 使他们的IPN脚本更新以使用http 1.1,因为 会被"悬挂"或花费很长时间才能获得'经过验证的响应。我们 包括有关如何通过添加一个来解决此问题的说明 HTTP请求中的"连接:关闭"标头。

,但显然这不起作用。

$header = "POST /cgi-bin/webscr HTTP/1.1rn";
$header .= "Host: $urlrn";
$header .= "Content-Type: application/x-www-form-urlencodedrn";
$header .= "Content-Length: " . strlen($req) . "rnrn";
$header .= "Connection: closern";

有什么想法吗?帮助非常感谢。

您在第二行上有 r n r n,它需要在最后一行...

$header = "POST /cgi-bin/webscr HTTP/1.1rn";
$header .= "Host: $urlrn";
$header .= "Content-Type: application/x-www-form-urlencodedrn";
$header .= "Content-Length: " . strlen($req) . "rn";
$header .= "Host: www.paypal.comrn"; 
$header .= "Connection: closernrn";

您还需要主机线。

我不知道它为何悬挂的答案,但是使用curl代替fsockopen似乎可以解决我的问题。我在这里使用了解决方案;

https://www.x.com/developers/paypal/documentation-tools/code-sample/216623

最新更新