Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Loops Paypal IPN 1.1 php脚本似乎循环了好几次_Loops_Paypal_Paypal Ipn - Fatal编程技术网

Loops Paypal IPN 1.1 php脚本似乎循环了好几次

Loops Paypal IPN 1.1 php脚本似乎循环了好几次,loops,paypal,paypal-ipn,Loops,Paypal,Paypal Ipn,我最近更新了新1.1版本的IPN脚本。它可以工作,付款也可以通过,但它多次运行我的成功代码(插入数据库,发送电子邮件)。e、 我做了一次试购,我的订单通过了22次,我收到了22封电子邮件 这是我的确切代码(实际的数据库和邮件代码是直接的-根本没有循环): 我就是这样做的: $arrRequestVars=$_POST; $cx=stream_context_create( array( "http"=>array( "method"=>

我最近更新了新1.1版本的IPN脚本。它可以工作,付款也可以通过,但它多次运行我的成功代码(插入数据库,发送电子邮件)。e、 我做了一次试购,我的订单通过了22次,我收到了22封电子邮件

这是我的确切代码(实际的数据库和邮件代码是直接的-根本没有循环):

我就是这样做的:

$arrRequestVars=$_POST;

$cx=stream_context_create(
    array(
        "http"=>array(
            "method"=>"POST",
            "header"=>"Content-type: application/x-www-form-urlencoded",
            "content"=>"cmd=_notify-validate&".http_build_query($arrRequestVars),
        ),
        "tls"=>array(
            "allow_self_signed"=>false,
        ),
        "ssl"=>array(
            "allow_self_signed"=>false,
        ),
    )
);
$strPayPalVerifyResponse=file_get_contents("https://".PAYPAL_API_HOSTNAME."/cgi-bin/webscr", false, $cx);
if(is_string($strPayPalVerifyResponse))
{
    $_arrParts=explode(" ", $http_response_header[0]);
    $nHTTPResponseCode=(int)$_arrParts[1];
    if($nHTTPResponseCode!==200)
        throw new Exception("Failed to verify wether request originated from PayPal. HTTP response code: ".$nHTTPResponseCode);

    if(trim($strPayPalVerifyResponse)=="INVALID")
        throw new Exception("PayPal did not recognize/validate the incoming IPN request. If the request was valid then mark as paid manually.");
    else if(trim($strPayPalVerifyResponse)!="VERIFIED")
        throw new Exception("Failed to verify wether request originated from PayPal. PayPal response: ".$strPayPalVerifyResponse);
}
else
    throw new Exception("Failed to verify wether request originated from PayPal.");

这是一个尽可能少的依赖关系示例。我建议对文件内容进行卷曲。

再多加一点最佳做法格式化,你可能会自己看到问题。好的……我现在觉得格式还可以(我缩进了})。我仍然看不出问题所在,尽管它必须是while()循环一次又一次地运行,但我不明白为什么它会运行不止一次?这与大多数人在脚本顶部使用的try error_reporting(-1)代码相同,请查看您发现了什么。
$arrRequestVars=$_POST;

$cx=stream_context_create(
    array(
        "http"=>array(
            "method"=>"POST",
            "header"=>"Content-type: application/x-www-form-urlencoded",
            "content"=>"cmd=_notify-validate&".http_build_query($arrRequestVars),
        ),
        "tls"=>array(
            "allow_self_signed"=>false,
        ),
        "ssl"=>array(
            "allow_self_signed"=>false,
        ),
    )
);
$strPayPalVerifyResponse=file_get_contents("https://".PAYPAL_API_HOSTNAME."/cgi-bin/webscr", false, $cx);
if(is_string($strPayPalVerifyResponse))
{
    $_arrParts=explode(" ", $http_response_header[0]);
    $nHTTPResponseCode=(int)$_arrParts[1];
    if($nHTTPResponseCode!==200)
        throw new Exception("Failed to verify wether request originated from PayPal. HTTP response code: ".$nHTTPResponseCode);

    if(trim($strPayPalVerifyResponse)=="INVALID")
        throw new Exception("PayPal did not recognize/validate the incoming IPN request. If the request was valid then mark as paid manually.");
    else if(trim($strPayPalVerifyResponse)!="VERIFIED")
        throw new Exception("Failed to verify wether request originated from PayPal. PayPal response: ".$strPayPalVerifyResponse);
}
else
    throw new Exception("Failed to verify wether request originated from PayPal.");