在与 paypal 集成时,我不断收到此警告: PHP警告:fgets() 期望参数 1 为资源,给定布尔值

发布于 2024-12-25 09:45:45 字数 1812 浏览 4 评论 0原文

可能的重复:
mysql_fetch_array() 需要参数 1是资源,在 select 中给出的布尔值

$url = $this->getAppParam('sandbox') ? 'www.sandbox.paypal.com' : 'www.paypal.com';
// OCT 31,2011 : now paypal uses ssl:// in url and port 443
$fp = fsockopen ('ssl://'.$url , 443, $errno, $errstr, 30);
XiError::assert($fp);


// post data back to PayPal system to validate
$header  = "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Host: $url\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
fputs ($fp, $header . $req);

// read the response data now
$return = false;
while( ! feof($fp)){
    //XITODO : Add this to tmp log file
    $response = fgets ($fp, 1024); //echo $res;
    if (strcmp ($response, 'VERIFIED') == 0) {
    $return = true;
    }

    if (strcmp ($response, 'INVALID') == 0) {
        $return = false;
    }
}

XiError::Assert

static function assert($condition, $msg = '', $type = self::ERROR)
    {
        // assert only if in debug mode
        if($condition || !(JDEBUG)){
            return true;
        }

        //raise error
        if($type == self::ERROR){
            self::raiseError('XI-ERROR', $msg);
        }

        //raise warning
        if($type == self::WARNING){
            self::raiseWarning('XI-WARNING', $msg);
        }

        // enqueue message
        XiFactory::getApplication()->enqueueMessage('XI-WARNING : '.$msg);
    }

中给出布尔值这是我正在使用的代码。正在生成警告 PHP 警告:fgets() 期望参数 1 为资源,布尔值在 /var/www/**** 中给出 一秒50次。 这导致我的服务器出现 4 GB 错误日志。有什么想法吗?

Possible Duplicate:
mysql_fetch_array() expects parameter 1 to be resource, boolean given in select

$url = $this->getAppParam('sandbox') ? 'www.sandbox.paypal.com' : 'www.paypal.com';
// OCT 31,2011 : now paypal uses ssl:// in url and port 443
$fp = fsockopen ('ssl://'.$url , 443, $errno, $errstr, 30);
XiError::assert($fp);


// post data back to PayPal system to validate
$header  = "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Host: $url\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
fputs ($fp, $header . $req);

// read the response data now
$return = false;
while( ! feof($fp)){
    //XITODO : Add this to tmp log file
    $response = fgets ($fp, 1024); //echo $res;
    if (strcmp ($response, 'VERIFIED') == 0) {
    $return = true;
    }

    if (strcmp ($response, 'INVALID') == 0) {
        $return = false;
    }
}

XiError::Assert

static function assert($condition, $msg = '', $type = self::ERROR)
    {
        // assert only if in debug mode
        if($condition || !(JDEBUG)){
            return true;
        }

        //raise error
        if($type == self::ERROR){
            self::raiseError('XI-ERROR', $msg);
        }

        //raise warning
        if($type == self::WARNING){
            self::raiseWarning('XI-WARNING', $msg);
        }

        // enqueue message
        XiFactory::getApplication()->enqueueMessage('XI-WARNING : '.$msg);
    }

This is my code which I am using. It is generating warning
PHP Warning: fgets() expects parameter 1 to be resource, boolean given in /var/www/****
50 times in a second.
This is causing 4 GB error log at my server. Any idea?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

奈何桥上唱咆哮 2025-01-01 09:45:45

不要使用套接字!在 php 中使用 CURL。当套接字不工作时,Curl 是 php 中的最佳选择。

do not use socket! use CURL in php.Curl is best option in php when socket not working.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文