PayPal监听器:通过对等方重置连接?

时间:2014-04-25 09:10:45

标签: php paypal paypal-ipn

我已经尝试过一切,但不断被同行重置"在尝试验证/验证时.. 这是我的提炼代码:

<?php
header('HTTP/1.1 200 OK');

$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) // $_POST looks OK to me..
    $req .= "&$key=".urlencode(stripslashes($value));

$fp = fsockopen("ssl://www.sandbox.paypal.com", 443, $errno, $errstr, 60); // true

$header  = "POST /cgi-bin/webscr HTTP/1.1\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Conection: Close\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";

fputs ($fp, $header . $req);
while (!feof($fp))
    {
    $res = fgets ($fp, 1024); // CONNECTION RESET BY PEER : (
    if ($res === "VERIFIED")    $response = "VERIFIED";
    if ($res === "INVALID") $response = "INVALID";
    }
fclose($fp);

为什么他们不跟我说话?!?

1 个答案:

答案 0 :(得分:1)

行。找到了一些示例代码,让我了解了所有内容:
https://github.com/paypal/ipn-code-samples/blob/master/paypal_ipn.php
- 收到&#34; VERIFIED&#34;后,我可以使用3年前的代码:)