【问题标题】:Digital Ocean hosting not allowing to read file using simplexml_load_file [closed]数字海洋托管不允许使用 simplexml_load_file 读取文件 [关闭]
【发布时间】:2014-08-13 07:15:51
【问题描述】:

我正在尝试使用 PHP 5.4 在 Digital Ocean 主机上使用以下代码读取 RSS 提要:

<?php

libxml_use_internal_errors(true);
 $rss = simplexml_load_file('http://www.filmfare.com/feeds/feeds-news.xml');
        echo 'RSS '.$rss;
foreach (libxml_get_errors() as $error) {
        // handle errors here
var_dump($error);
    }
libxml_clear_errors();
?>

代码刚刚返回

RSS object(LibXMLError)#2 (6) { ["level"]=> int(1) ["code"]=> int(1549) ["column"]=> int(0) ["message"]=> string(78) "failed to load external entity "http://www.filmfare.com/feeds/feeds-news.xml" " ["file"]=> string(0) "" ["line"]=> int(0) } bool(false)

当我在使用 PHP 5.3 的 Go Daddy 主机上运行时,相同的代码正在返回完美的结果。

我已经检查并且两个主机上php.ini 中的以下设置相同

allow_url_fopen=On
allow_url_include = Off

然后我也尝试了以下 CURL sn-p,

<?php
$source='http://www.filmfare.com/feeds/feeds-news.xml';
$rcUrlHandle = curl_init($source);
curl_setopt($rcUrlHandle,CURLOPT_RETURNTRANSFER,true);
$sData = curl_exec($rcUrlHandle);
if(curl_errno($rcUrlHandle))
{
   echo 1;
    print_r(curl_getinfo($rcUrlHandle));
    curl_close($rcUrlHandle);
}
else
{
    echo 2 ;
    print_r($sData);
    curl_close($rcUrlHandle);
}
?>

Digital Ocean 仍然没有返回任何内容,而 Go Daddy 则返回完美无缺。任何想法?

allow_url_fopen     On  On
allow_url_include   Off Off

【问题讨论】:

  • 如果您执行phpinfo(),allow_url_fopen 会显示什么值?
  • 您可以尝试wgetcurl 提要看看会发生什么吗?

标签: php linux digital-ocean


【解决方案1】:

发现DigitalOcean IP没有被端方加入白名单。与他们一起启动了这个过程,应该在几个小时内完成。谢谢大家。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-27
    • 1970-01-01
    • 1970-01-01
    • 2019-11-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多