Solved

PHP RSS feed from intranet site

Posted on 2013-01-30
10
662 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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:Marcus Bointon
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
change password links 7 73
php call to a non-object 3 32
Form Processing in PHP 11 31
how to handle $x_amount to payment gateway in php - stumped. 14 13
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

911 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

22 Experts available now in Live!

Get 1:1 Help Now