Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.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
Php 使用未定义的常量主机-假定';主机';paypal类错误(codeigniter库)_Php_Codeigniter_Paypal_Paypal Sandbox_Paypal Ipn - Fatal编程技术网

Php 使用未定义的常量主机-假定';主机';paypal类错误(codeigniter库)

Php 使用未定义的常量主机-假定';主机';paypal类错误(codeigniter库),php,codeigniter,paypal,paypal-sandbox,paypal-ipn,Php,Codeigniter,Paypal,Paypal Sandbox,Paypal Ipn,我正在使用名为paypal_类的codeigniter库。一切都很好,但在验证ipn函数时,我得到了这个错误使用未定义的常量主机-假定为“主机”这一定是邮件未发送给用户的原因。一无所获 我是贝宝的新手。所以我希望有一个详细的解决方案。非常感谢。请询问您可能需要的任何其他信息 错误位于此行: $fp = fsockopen($url_parsed[host], "80", $err_num, $err_str, 30); 在哪里 $url_parsed = parse_url($this-&

我正在使用名为paypal_类的codeigniter库。一切都很好,但在验证ipn函数时,我得到了这个错误<代码>使用未定义的常量主机-假定为“主机”这一定是邮件未发送给用户的原因。一无所获

我是贝宝的新手。所以我希望有一个详细的解决方案。非常感谢。请询问您可能需要的任何其他信息


错误位于此行:

 $fp = fsockopen($url_parsed[host], "80", $err_num, $err_str, 30);
在哪里

$url_parsed = parse_url($this->paypal_url);
以下是ipn功能:

    function validate_ipn() {

    // parse the paypal URL
    $url_parsed = parse_url($this->paypal_url);

    // generate the post string from the _POST vars aswell as load the
    // _POST vars into an arry so we can play with them from the calling
    // script.
    $post_string = '';
    foreach ($_POST as $field => $value) {
        $this->ipn_data["$field"] = $value;
        $post_string .= $field . '=' . urlencode(stripslashes($value)) . '&';
    }
    $post_string.="cmd=_notify-validate"; // append ipn command
    // open the connection to paypal
    $fp = fsockopen($url_parsed['host'], "80", $err_num, $err_str, 30);
    if (!$fp) {

        // could not open the connection.  If loggin is on, the error message
        // will be in the log.
        $this->last_error = "fsockopen error no. $errnum: $errstr";
        $this->log_ipn_results(false);
        return false;
    } else {

        // Post the data back to paypal
        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");

        // loop through the response from the server and append to variable
        while (!feof($fp)) {
            $this->ipn_response .= fgets($fp, 1024);
        }
        fclose($fp); // close connection
    }

    if (preg_match("/VERIFIED/i", $this->ipn_response)) {

        // Valid IPN transaction.
        $this->log_ipn_results(true);
        return true;
    } else {

        // Invalid IPN transaction.  Check the log for details.
        $this->last_error = 'IPN Validation Failed.';
        $this->log_ipn_results(false);
        return false;
    }
}

您需要更改以下内容:

 $fp = fsockopen($url_parsed[host], "80", $err_num, $err_str, 30);

然后在此处调试返回值执行以下操作:

$url_parsed = parse_url($this->paypal_url);
var_dump($url_parsed);

host
更改为
$host
。它给了我:消息:未定义索引:将
$url\u解析的[host]
更改为
$url\u解析的['host']
@NicholasPickering我仍然没有收到邮件..:(然后是其他错误-您的服务器未设置为能够发送邮件,或者您的设置不正确。无论哪种情况,都有错误。您发布的任何代码都与邮件无关。
$url_parsed = parse_url($this->paypal_url);
var_dump($url_parsed);