Embedding RSS Feeds with PHP.

dazadz

New Member
Messages
9
Reaction score
0
Points
0
I have been trying to embed RSS feeds on my site with PHP so it is readable by search engines. I use http://rssfeedreader.com/ to get the codes, it gives javascript and php scripts. The javascript works fine but when I try the php script I just get a blank space on my page where the feed should be. Here is an example of the php script for a Google Sports News feed:

<?php
$olderror_reporting =error_reporting(0);
include ("http://rssfeedreader.com/rss3/rss.php?url=http%3A%2F%2Fnews.google.com%2Fnews%3Fned%3Dus%26topic%3Ds%26output%3Drss&newpage=1&chead=1&atl=&desc=1&owncss=&eleminate=&auth=1&dts=1&width=300&max=5&tlen=0&rnd=1&bt=3&bs=Double&nmb=&ntb=&naf=&nst=&nwd=0&nht=0&dlen=0&lstyle=-1&lc=Blue&bg=White&bc=Gray&spc=&ims=&tc=&ts=11&tfont=Verdana,+Arial,+Sans-serif&rf=".$HTTP_SERVER_VARS['SERVER_NAME'].$HTTP_SERVER_VARS['PHP_SELF']."&phpout=1");
error_reporting($olderror_reporting);
?>

I use php includes for my headers etc so I know the include function works on my domain, unless it is the fact that I am including an off-site file that makes a difference? I have looked for help on this but I've hit a bit of a dead end. Can anyone offer any suggestions as to what I'm doing wrong please? Any help will be greatly appreciated.


EDIT: I just tried to write my own include for a Superbikes feed, here is what I added:

<?php
include ("http://www.worldsbk.com/en/news?format=feed&type=rss");
?>

And this is what appeared on my page:


Warning: include() [function.include]: URL file-access is disabled in the server configuration in /home/dazadz/public_html/rss_test.php on line 79

Warning: include(http://www.worldsbk.com/en/news?format=feed&type=rss) [function.include]: failed to open stream: no suitable wrapper could be found in /home/dazadz/public_html/rss_test.php on line 79

Warning: include() [function.include]: Failed opening 'http://www.worldsbk.com/en/news?format=feed&type=rss' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/dazadz/public_html/rss_test.php on line 79


This is what makes me wonder if it is a permissions issue with the server rather than a mistake in the script, but I don't know.
 
Last edited:

zapzack

New Member
Messages
606
Reaction score
19
Points
0
If you read the error, it clearly states the issue..

Warning: include() [function.include]: URL file-access is disabled in the server configuration in /home/dazadz/public_html/rss_test.php on line 79

From this, I can tell you that the PHP configuration does NOT allow URL includes for security reasons.. I suggest you try the curl library..

PHP:
<?php
    $curl = curl_init("http://www.worldsbk.com/en/news?format=feed&type=rss");
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, false);
	$content = curl_exec($curl);
?>
 
Last edited:

dazadz

New Member
Messages
9
Reaction score
0
Points
0
Thanks for your help and thanks for clarifying where my problem lies. I will try your code as soon as I get back to my other PC.
Edit:
Tried it and it works great, thanks once again. Just trying to figure out how to format the imported feed now, I tried pasting the link from the rssfeedreader link in my first post and it imports the feed ok but the formatting is a mess.
Anyway, the main thing is that it works, I wish I had asked for help here months ago!
 
Last edited:
Top