Solved

PHP RSS feed from intranet site

Posted on 2013-01-30
10
670 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 17

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 17

Expert Comment

by:Chris Harte
ID: 38834944
Have you tried it without the file_exists?
0
Technology Partners: 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!

 

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
 
LVL 17

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 17

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

740 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