Php 贝宝:ipn响应有问题

Php 贝宝:ipn响应有问题,php,paypal,Php,Paypal,我可以使用IPN从paypal获得验证的答案 我正在通过notify_url从PayPal接收帖子数据。然后我将它发送回PayPal,并在数据前面使用cmd=\u notify-validate 使用PayPals文档化的代码,我用它向PayPal发送消息 $header = "POST /cgi-bin/webscr HTTP/1.1\r\n"; // HTTP POST request $header.= "Content-Type: application/x-www-form-urlen

我可以使用IPN从paypal获得验证的答案 我正在通过notify_url从PayPal接收帖子数据。然后我将它发送回PayPal,并在数据前面使用cmd=\u notify-validate

使用PayPals文档化的代码,我用它向PayPal发送消息

$header = "POST /cgi-bin/webscr HTTP/1.1\r\n"; // HTTP POST request
$header.= "Content-Type: application/x-www-form-urlencoded\r\n";
$header.= "Host: www.sandbox.paypal.com\r\n";
$header.= "Content-Length: " . strlen($req) . "\r\n";
$header.= "Connection: Close\r\n\r\n";
$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
然后我用这个

if (!$fp) {
    // HTTP ERROR; 
} else {
    var_dump(fputs($fp, $header . $req));
    while (!feof($fp)) {
        $res = stream_get_contents($fp, 1024); 
        if (strcmp ($res, "VERIFIED") == 0) {
            //Transaction verified
        }
    }
}
事实上,我有两个$res(由于while循环)。第一个似乎不感兴趣,第二个似乎不感兴趣

55 GMT
Connection: close
Set-Cookie: X-PP-SILOVER=name%3DSANDBOX3.WEB.1%26silo_version%3D880%26app%3Dslingshot%26TIME%3D1273590100; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT
Set-Cookie: Apache=10.72.128.11.1416751435364358; path=/; expires=Tue, 15-Nov-44 14:03:55 GMT
Vary: Accept-Encoding
Strict-Transport-Security: max-age=14400
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8

8
VERIFIED
0
看起来第一部分是一个标题,第二部分(8-0)是真实的响应,但是为什么我有这个0和8?通常人们使用

 if (strcmp ($res, "VERIFIED") == 0) {
要检查$res是否已验证。。。因此,我可以认为,响应是“核实”,使用一些类似于< /P>
if(strstr($res,'VERIFIED')) {
请帮忙


谢谢

我和你有同样的问题。我使用strstr($res,'VERIFIED')检查通知是否已验证。

我遇到了完全相同的问题,并且能够以相同的方式解决它。如果我使用PayPal的示例代码,我根本没有得到任何响应

但我在这里遇到了一些使用cURL的方法: .

我需要按照以下说明安装cURL:

还可以下载并使用脚本注释中的cacert.pem

我仍然不确定为什么stream_get_contents()返回标题。如果你已经弄明白了,你能更新这个吗