Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

PHP RSS feed from intranet site

Posted on 2013-01-30
10
Medium Priority
?
776 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 750 total points
ID: 38835073
0
 
LVL 17

Assisted Solution

by:Chris Harte
Chris Harte earned 750 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

670 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