Solved

PHP RSS feed from intranet site

Posted on 2013-01-30
10
655 Views
Last Modified: 2014-01-26
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
Comment
Question by:ubya308
10 Comments
 
LVL 16

Expert Comment

by:Chris Harte
ID: 38834640
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
 

Accepted Solution

by:
ubya308 earned 0 total points
ID: 38834653
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
 
LVL 16

Expert Comment

by:Chris Harte
ID: 38834944
Have you tried it without the file_exists?
0
 

Author Comment

by:ubya308
ID: 38835027
Yes - no joy.
0
 
LVL 5

Assisted Solution

by:Php_expert
Php_expert earned 250 total points
ID: 38835073
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 16

Assisted Solution

by:Chris Harte
Chris Harte earned 250 total points
ID: 38835217
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
 

Author Comment

by:ubya308
ID: 38842781
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
 
LVL 16

Expert Comment

by:Chris Harte
ID: 38843202
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
 
LVL 25

Expert Comment

by:Squinky
ID: 39686271
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
 

Author Closing Comment

by:ubya308
ID: 39809799
Not fully answered
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to dynamically set the form action using jQuery.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now