0
以下是我的代码,我使用:贝宝IPN返回空字符串,PHP
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->paypal_url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: ' . $url_parsed['host']));
$res = curl_exec($ch);
curl_close($ch);
这个 - > paypal_url是沙箱API URL和url_parsed [“主机”]是沙盒贝宝的主机名,这些都是正确的,但我遇到的问题是每次调用$ res都是空的。
前PayPal的开发者网站得到这个代码,我用下面的代码:
$fp = fsockopen('ssl://' . $url_parsed['host'],"443",$err_num,$err_str,30);
fputs($fp, "POST $url_parsed[path] HTTP/1.1\r\n");
fputs($fp, "Host: $url_parsed[host]\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: ".strlen($post_string)."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $post_string . "\r\n\r\n");
,并未能打开套接字错误发生。我使用这行代码: $ fp = fsockopen($ url_parsed ['host'],“80”,$ err_num,$ err_str,30);
我得到这样的回应:
Server:
HTTP/1.0 302 Moved Temporarily
Location: https://www.sandbox.paypal.com
Server: BigIP
Content-Length: 0
X-Cache: MISS from proxyco.confiz.com
X-Cache-Lookup: MISS from proxyco.confiz.com:3128
Via: 1.0 proxyco.confiz.com:3128 (squid/2.6.STABLE21)
Connection: close
请帮我找到这个解决方案。