在与 paypal 集成时,我不断收到此警告: PHP警告:fgets() 期望参数 1 为资源,给定布尔值
$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 warningPHP 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不要使用套接字!在 php 中使用 CURL。当套接字不工作时,Curl 是 php 中的最佳选择。
do not use socket! use CURL in php.Curl is best option in php when socket not working.