让我首先说我不是一个真正的开发人员。几年前,我将下面的代码拼凑在一起,尽管直到上周我还没有真正理解它。从上周开始,每次我得到一个PayPal IPN我得到一个110连接超时套接字错误!套接字超时IPN
如果我直接在浏览器我得到以下
警告到了页:的fsockopen()[function.fsockopen]:无法连接到SSL://www.paypal.com:443(连接超时)在paypal_ipn.php5在线37
以下是我的paypal_ipn.php5任何帮助,将不胜感激的代码。
<?php
error_reporting(E_ALL^E_NOTICE);
$email = $_GET['ipn_email'];
$header = "";
$emailtext = "";
$req = 'cmd=_notify-validate';
if(function_exists('get_magic_quotes_gpc'))
{
$get_magic_quotes_exists = true;
}
foreach ($_POST as $key => $value)
{
if($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1)
{
$value = urlencode(stripslashes($value));
}
else
{
$value = urlencode($value);
}
$req .= "&$key=$value";
}
// Post back to PayPal to validate new http 1.1
$header .= "POST /cgi-bin/webscr HTTP/1.1\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .="Host: www.paypal.com\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n";
$header .="Connection: closer\n\r\n";
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);
if (!$fp)
{
mail("[email protected]", "socket error!", "socket error!", "$errno $errstr");
}
else
{
fputs ($fp, $header . $req);
while(!feof($fp))
{
$res = fgets ($fp, 1024);
if(stristr($res, 'VERIFIED') !== FALSE)
{
//good payment process transaction
//code removed to make my post smaller
}
elseif(stristr($res, 'INVALID') !== FALSE)
{
// If 'INVALID', send an email.
mail("[email protected]", "Live-INVALID IPN", "Invalid \n\n\n res = $res \n\n\n req= $req",$error_email);
}
}
}
fclose ($fp);
?>
非常感谢。在我和我的网站托管公司谈论获得新证书后,我是否需要更新我的代码? – ultimacanam
在第52行,当你有新的SSL证书时,你需要将1024更改为2048。此外,你可能有一个SHA-2证书,但你的代码只能在1024编码。你可以尝试简单地改变第52行,看看是否可以解决问题: EDIT $ res = fgets($ fp,1024);阅读:$ res fgets($ fp,2048); – DimensionX
查看您的代码,在执行代码的其余部分之前,它似乎首先检查证书的有效性;因此,我怀疑仅仅更改这条线就能解决问题,因为只有在您的证书通过PayPal验证之后才能执行。不过,您需要更改该行,以便在升级证书后再次使用该行。 – DimensionX