我很容易從PayPal使用IPN獲得驗證答案 我通過notify_url從PayPal接收POST數據。然後我用cmd = _notify-驗證數據的正面將它發回PayPal。貝寶:與ipn響應的問題
使用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(由於同時循環)。第一似乎並不感興趣,第二是
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 VERIFIED 0)是真正的迴應,但爲什麼我有這個0 8?通常人們使用
if (strcmp ($res, "VERIFIED") == 0) {
要檢查$水庫進行驗證。所以我可以認爲響應「已驗證」,使用類似
if(strstr($res,'VERIFIED')) {
一些幫助嗎?!?
謝謝