Page 1 of 1

file_get_contents rss breaks with relative url

Posted: Wed Apr 12, 2006 3:07 pm
by CSTechie
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


hello.

I'm trying to grab the content of an RSS feed.  This fails when I use a proxy server because it can't resolve the relative url's in the rss feed.   In the RSS feed I have:  <?xml-stylesheet type="text/xsl" href="/xsl/rss2-sitename.xsl"?>

My environment is a mac.  

If I don't use the proxy server, I can grab the contents of the page.

My code has this to get the rss content:

Code: Select all

$url = 'http://www.url_location.com';

function get_rss(){
		$options = array(
			'http' => array(
				'header' => "Proxy: http://www.proxy.com:80"
			)
		); 
	
               $context = stream_context_create($options);
               $this->index = file_get_contents("$this->url", 
	           false, $context)
	           or die ("No RSS feed for you.");					   
		
}
Anyone do this or have a better way to do this?

Thanks for the help!


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]