开发者

Paypal IPN cannot get verified

I am trying to implement Paypal IPN but it never reaches the url I've set. I've written a script to log visits to this url and all I get are my visits.

How long does it take for Paypal to sent the notification?

EDIT

IPNs suddenly started to come but now I can't verify...Here is the code:

$url = 'https://www.paypal.com/cgi-bin/webscr';
        $postdata = '';
        foreach ($_POST as $i => $v) {
            $postdata .= $i . '=' . urlencode($v) . '&';
        }
        $postdata .= 'cmd=_notify-validate';

        $web = parse_url($url);
        if ($web['scheme'] == 'https') {
            $web['port'] = 443;
            $ssl = 'ssl://';
        } else {
            $web['port'] = 80;
            $ssl = '';
        }
        $fp = @fsockopen($ssl . $web['host'], $web['port'], $errnum, $errstr, 30);

        if (!$fp) {
            echo $errnum . ': ' . $errstr;
        } else {
            fputs($fp, "POST " . $web['path'] . " HTTP/1.1\r\n");
            fputs($fp, "Host: " . $web['host'] . "\r\n");
            fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
            fputs($fp, 开发者_JAVA技巧"Content-length: " . strlen($postdata) . "\r\n");
            fputs($fp, "Connection: close\r\n\r\n");
            fputs($fp, $postdata . "\r\n\r\n");

            while (!feof($fp)) {
                $info[] = @fgets($fp, 1024);
            }
            fclose($fp);
            $info = implode(',', $info);
            if (eregi('VERIFIED', $info)) {

            } else {

}

}


I already commented above. But I'm pretty sure the html encoded & is messing up your callback.

There's big difference between URL encoding and HTML encoding.

Change this '&' to this '&'. & is a url/post character used to separate different sets of key/value pairs. By changing it to &, you made your whole callback a single value.

Also, just some advice, but I would ditch this

if (eregi('VERIFIED', $info)) {} else {}

and replace it with this

if (preg_match('/VERIFIED/', $info))  {} else {}

eregi is depreciated.
http://php.net/manual/en/function.eregi.php

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜