有人可以向我解释为什么这会一直返回HTTP 302响应代码吗?
我已经完成了几十次测试付款,此时我就开始拔头了!
编辑 ......第二行应该是:
$data = 'cmd=_notify-validate&' . http_build_query($_POST);
$conn = fsockopen("ssl://www.sandbox.paypal.com", 443, $n, $m, 30);
$data = http_build_query($_POST);
$headers =
"POST /cgi-bin/webscr HTTP/1.0\r\n" .
"Host: www.sandbox.paypal.com\r\n" .
"Content-Type: application/x-www-form-urlencoded\r\n" .
"Content-Length: " . strlen($data) . "\r\n";
fputs($conn, "$headers\r\n$data");
// loop until end of response
while (!feof($conn)) {
$r = fgets($conn, 1024);
$results .= $r;
if (strcmp($r, "VERIFIED") === 0) {
$success = true;
fclose($conn);
break;
}
if (strcmp($r, "INVALID") === 0) {
$success = false;
fclose($conn);
break;
}
}
var_dump($results);
给我:
HTTP/1.1 302 Found
Date: Sun, 05 Apr 2015 01:05:19 GMT
Server: Apache
X-Frame-Options: SAMEORIGIN
Set-Cookie: c9MWDuvPtT9GIMyPc3jwol1VSlO=jpXL4slHSFMW62IfhXt98Ecs62rNGxGaMe9do0PXFTJCvKNoSWrzcNKb58XDiADlB6Vd4sSqrQt-mdqdmwlhYjnS-vrmseHmpUXfgJB02GXawXmw-0ORrjpAlcs9MjNzjerB9260RGRm1oASkzbL6fKubJohZlpTuM9ejW-hubbqKhagUSvvO7jyvT-6qewxY72pyDVtulr0FV3X3b5N8HwihlK2nzr9LK6NbwwmrzH3gOsHz7GQ4Mt7M8y; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: -1ILhdyICORs4hS4xTUr41S8iP0=uyJXnbFu20vqgtvwa1990vbI5M5aG7JM-hGvulSB7_Mg0vU_l6yRwHrZj3FFHc1v8V_6jaqEahhmS6Wt; expires=Sat, 31-Mar-2035 01:05:19 GMT; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: cookie_check=yes; expires=Wed, 02-Apr-2025 01:05:19 GMT; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: consumer_display=USER_HOMEPAGE%3d0%26USER_TARGETPAGE%3d0%26USER_FILTER_CHOICE%3d0%26BALANCE_MODULE_STATE%3d1%26GIFT_BALANCE_MODULE_STATE%3d1%26LAST_SELECTED_ALIAS_ID%3d0%26SELLING_GROUP%3d1%26PAYMENT_AND_RISK_GROUP%3d1%26SHIPPING_GROUP%3d1%26HOME_VERSION%3d1%26MCE2_ELIGIBILITY%3d4294967295; expires=Wed, 02-Apr-2025 01:05:19 GMT; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: Apache=10.72.108.11.1428195919710342; path=/; expires=Tue, 28-Mar-45 01:05:19 GMT
Vary: Accept-Encoding,User-Agent
Connection: close
Set-Cookie: X-PP-SILOVER=name%3DSANDBOX3.WEB.1%26silo_version%3D880%26app%3Dappdispatcher%26TIME%3D1334452309; 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.1428195919696329; path=/; expires=Tue, 28-Mar-45 01:05:19 GMT
Location: https://www.sandbox.paypal.com/home
Strict-Transport-Security: max-age=14400
Content-Type: text/html; charset=ISO-8859-1
注意我我使用ssl://
和端口443。
答案 0 :(得分:1)
解决方案:忘记在POST请求数据中加入cmd=_notify-validate
。
答案 1 :(得分:0)
您应该尝试使用https://www.sandbox.paypal.com
作为终点。我使用它作为我的终端