• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 854
  • Last Modified:

PHP RSS feed from intranet site

I am trying to implement some php which takes data from an RSS feed on my corporate site, however I can't seem to get the PHP to see the XML.

The php is running on a localhost server and is running fine. The localhost server is on my laptop which is logged in.

The RSS feed is held on an intranet.

I can see the RSS feed if I type the URI into Chrome or IE (without entering additional passwords etc).

I can see the RSS feed if I type the URI into FeedDemon (without entering additional passwords etc).

I can't see the file with the following code.

<?php
$url = "http://myintranet.mydomain.com/listfeed.aspx?List=%7B96AD9A92%2D7513%2D4DB6%2D926D%2DD9EA9E42ADB1%7D&Source=http%3A%2F%2Fmyintranet%2Emydomain%2Ecom%2Fcalendars%2Easpx";
if (file_exists($url)) {
    $xml = simplexml_load_file($url);
 
    print_r($xml);
} else {
    exit('Failed to open test.xml.');
}
?>

The actual URI is considerably longer (234 characters).

How can I access this?

Thanks

Mike
0
ubya308
Asked:
ubya308
3 Solutions
 
Chris HarteThaumaturgeCommented:
Try this

if (file_exists($url)) 
{
//    $xml = simplexml_load_file($url);
    $temp = file_get_contents($url);
    $xml = simplexml_load_string($temp);
 
    print_r($xml);
} 
else 
{
    exit('Failed to open test.xml.');
}

Open in new window

0
 
ubya308Author Commented:
Hi - the problem seems to be that the if(file_exists($url)) test is evaluated to be false.

In other words it can't see anything at that address, even though Chrome & FeedDemon can.
0
 
Chris HarteThaumaturgeCommented:
Have you tried it without the file_exists?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ubya308Author Commented:
Yes - no joy.
0
 
Php_expertCommented:
0
 
Chris HarteThaumaturgeCommented:
Then all I can think of is permissions. Does your php server have the ability to access the feed server?

Also your uri contains a lot of special characters. Have you tried escaping them instead?

eg "http\:\/\/" as opposed to http%3A%2F%2F
0
 
ubya308Author Commented:
I think you may be right MunterMan - do you know how I can change the identity of my localhost server so it looks like me?
0
 
Chris HarteThaumaturgeCommented:
Is this windows or linux?
Are you using apache or iis?

I am guessing iis under windows (because of aspx), in which case have a read of this

http://www.php.net/manual/en/install.windows.installer.msi.php#96338
0
 
Marcus BointonCommented:
I recommend you don't try and decode general RSS feeds with your own code. They vary massively and you'll be making a huge amount of work for yourself. Take a look at Zend Framework's Zend_Feed_Reader for a nice easy one, or the lower-level Zend_Feed if you want more flexibility. They can normalise feed contents (for example what the publication date is called can vary a lot), will cope with all sorts of different formats: RSS 1,0, 2.0, Atom etc, and also not fail is the feed is not valid XML. You can use them by themselves, no need to use any other bits of the framework.

You may have fopen_wrappers disabled which would prevent file_exists from checking the URL.

@MunterMan, that encoding is correct for embedding one URL inside another; URLs don't use \ for escaping.
0
 
ubya308Author Commented:
Not fully answered
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now