Jump to content

guid element breaks my rss php code


romeoyankee

Recommended Posts

hey guys.. great site by the way. 

 

First of all I am a relative php newb but am able to read and search and learn on my own.  In saying that I have read and searched everything I think I can so I will ask here...

 

I am using a script called magpierss which is supposed to parse rss files and then using my code I can combine multiple rss feeds and then create a new rss feed from that..

 

I seem to be having a problem with my code though...  Occasionaly there is a link in an rss feed that seems to break the php code i have written somehow.

 

Best way I can explain it is this..  if you go to the site.. http://www.cyow.ca/magpie/indextest2.php you will see that it might be working or not.. If its not run it through a feed validator

 

I am combining about 9 rss feeds into 1. Each individual rss feed shows up fine and will validate correctly on its own. 

 

Once I combine the feeds and create my new feed the new rss feed seems to break.  I mean that when you go to the link http://www.cyow.ca/magpie/indextest2.php  you only see the first few stories being displayed , if that, up until the feed gets broken.  I have set it so there should be 30 stories.  If you were to view the source though everything looks fine.. 

 

It wont validate because I think it has something to do with a guid element.. I dont really know what that is though.

 

http://feedvalidator.org/check.cgi?url=http%3A%2F%2Fwww.cyow.ca%2Fmagpie%2Findextest2.php

 

here is the script I am using to call all this info

 

<?php 
require_once('magpierss/rss_fetch.inc');
$urls = array();
array_push($urls,"http://www.aviation.ca/component/option,com_rss/feed,

RSS2.0/no_html,1/");
array_push($urls,"http://www.avweb.com/avwebflash/index.xml");
array_push($urls,"http://rssfeeds.usatoday.com/TP-TodayInTheSky/");
array_push($urls,"http://www.achannel.ca/ottawa/news.xml");
array_push($urls,"http://rss.msnbc.msn.com/id/3033632/device/rss/rss.xml");
array_push($urls,"http://planenews.com/rss2.php");
array_push($urls,"http://rss.cbc.ca/ottawanews.xml");
array_push($urls,"http://z.about.com/6/g/airtravel/b/index.xml");
array_push($urls,"http://www.ctv.ca/generic/generated/freeheadlines/rdf/allNewsRss.xml");
array_push($urls,"http://aviation-safety.net/rss/rss-asnnews.xml");
array_push($urls,"http://rss.canada.com/get/?F240");

$feedlimit=30;
$webmasteremail="admin@cyow.ca";
$rssdescription="Cyow.ca News Feed";
$rsstitle="Cyow.ca News Feed";
$sitelink="http://www.cyow.ca";
$managingEditor="admin@cyow.ca";



$feedlimit=$feedlimit+1;
$myrssfeeds=array();
foreach($urls as $urllink)
{
$rss1=fetch_rss($urllink);

if(count($rss1->items)>$feedlimit)
{
	$tofetch=$feedlimit;
}
else
{
	$tofetch=count($rss1->items);
}
$counter=0;
foreach ($rss1->items as $item) 
{
	if($counter<$tofetch)
	{
		array_push($myrssfeeds,$item);
	}
	$counter++;
}
}


for($k=0;$k<count($myrssfeeds);$k++)
for($j=$k;$j<count($myrssfeeds);$j++)
{


if(strtotime($myrssfeeds[$k][pubdate])<strtotime($myrssfeeds[$j][pubdat

e]))
{
	$swapper=$myrssfeeds[$j];
	$myrssfeeds[$j]=$myrssfeeds[$k];
	$myrssfeeds[$k]=$swapper;
}
}

echo <<<END
<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0">
<channel>
END;
?>
<?php
echo "	<docs>http://backend.userland.com/rss092</docs>";
echo"	<title>".$rsstitle."</title>";
echo"	<link>".$sitelink."</link>";
echo"	<description>".$rssdescription."</description>";
echo"	<managingEditor>".$managingEditor."</managingEditor>";
echo"	<webMaster>".$webmasteremail."</webMaster>";
$builddate=gmdate('D, d M Y H:i:s', time()) . ' GMT';

print("<lastBuildDate>".$builddate."</lastBuildDate>\n");

for($i=0;$i<$feedlimit;$i++)
{
if($myrssfeeds[$i][pubdate]!="")
{
	print("<item>");
	print("<title>".$myrssfeeds[$i][title]."</title>");


print("<pubDate>".$myrssfeeds[$i][pubdate]."</pubDate>");
	print("<link>".$myrssfeeds[$i][link]."</link>");
	$description=$myrssfeeds[$i][description];
	$description=preg_replace('/<img[^>]*>/i', '', 

$description);
	$description=str_replace("&"," & ", $description);
	$description=str_replace("<","<", $description);
	$description=str_replace('>','>', $description);


print("<description>\n".$description."\n</description>");
	print("</item>");
}
}
echo <<<END
</channel>
</rss>
END;
?> 

 

 

What can I do to fix the guid element error??

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.