How to handle a feed with . rss extension

Asked

Viewed 102 times

1

I receive an XML via a feed URL with extension .RSS. I am trying to read the XML and was not successful. I tried it in the following ways:

$url = 'http://www.feedaqui.com.br/recent.rss';
$xml = simplexml_load_file($url);

$url = 'http://www.feedaqui.com.br/recent.rss';
$xml = simplexml_load_string(file_get_contents($url));

Generating the error:

Warning: simplexml_load_file(): I/O warning : failed to load external entity
  • What mistake it makes?

  • I edited and added the bug.

  • 1

    In your php.ini, change the allow_url_fopen setting to on or use Curl.

  • 1

    I used Curl and gist 5405671 tip from betweenbrain https://gist.github.com/betweenbrain/5405671

  • 1

    If it works, add a reply and validate after two days.

  • The extension in the file/url nomenclature does not influence anything. The important thing is the content-type and the content itself. For example, the URL can be http://.../feed.exe and if the . exe returns a content-type text type, then it will be treated as text.

Show 1 more comment

1 answer

0


$curl = curl_init();

curl_setopt_array($curl, Array(
    CURLOPT_URL            => 'http://www.feedaqui.com.br/recent.rss';
    CURLOPT_USERAGENT      => 'spider',
    CURLOPT_TIMEOUT        => 120,
    CURLOPT_CONNECTTIMEOUT => 30,
    CURLOPT_RETURNTRANSFER => TRUE,
    CURLOPT_ENCODING       => 'UTF-8'
));

$data = curl_exec($curl);

curl_close($curl);

$xml = simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.