Hi
I have the following code written to create rss feed using the simplepie xml parser. It is showing all title, description, etc properly. But I also want the media:thumbnail to be seen in the xml feed.
<?php
require_once(‘php/newsblocks.inc.php’);
header(‘Content-type:text/html; charset=utf-8’);
?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=“http://www.w3.org/1999/xhtml” xml:lang=“en-US” lang=“en-US”>
<head>
<title>Mash of feeds</title>
<?
require(“simplepie/simplepie.inc”);
require_once(‘simplepie/shorten.inc’);
?>
</head>
<body>
<?php
$feed = new SimplePie();
$feed->set_feed_url(‘http://www.example.com/feed/’);
$feed->enable_cache(true);
$feed->set_cache_duration(3600);
$feed->set_cache_location(‘cache’);
$feed->init();
$feed->handle_content_type();
// code to to get xml
$file= fopen("results.xml", "w");
$_xml ="<?xml version=\\"1.0\\" encoding=\\"UTF-8\\" ?>\\r\
";
$_xml .="<rss version='2.0' xmlns:blogChannel='http://backend.userland.com/blogChannelModule' xmlns:dc='http://purl.org/dc/elements/1.1/'
xmlns:content=‘http://purl.org/rss/1.0/modules/content/’ xmlns:atom=‘http://www.w3.org/2005/Atom’ xmlns:media=‘http://search.yahoo.com/mrss/’>";
$_xml .="<channel>\\r\
";
$_xml .="<title>Blogs</title>";
$_xml .="<link>http://www.example.com</link>";
$_xml .="<description>Latest updates of bollywood blogs</description>";
$_xml .="<atom:link href='results.xml' rel='self' type='application/rss+xml' />";
// code to get xml ends
foreach ($feed->get_items(0,3) as $item)
{
//echo $item->get_title();
//echo “<br />”;
$_xml .="\ <item>\\r\
“;
$_xml .=”\ \ <link>" . $item->get_permalink() . “</link>\r
“;
$_xml .=”\ \ <description>” . shorten($item->get_content(),50) . “</description>\r
“;
$_xml .=”\ \ <title>” . $item->get_title() . “</title>\r
“;
$_xml .=”<dc:date>” . $item->get_date(‘Y-m-d’) . “</dc:date>”;
$_xml .=“<guid isPermaLink=‘false’>” . $item->get_title() . “</guid>”;
$_xml .=“<media:group><media:thumbnail url=‘http://www.example.com/example.jpg’ type=‘image/jpeg’ width=‘126’ height=‘126’ /><media:title> FeedForAll file sample </media:title></media:group>”;
$_xml .="\ </item>\r
";
} // main for each item ends
$_xml .="</channel>";
$_xml .="</rss>";
fwrite($file, $_xml);
fclose($file);
echo "XML has been written. <a href=\\"results.xml\\">View the XML.</a>";
?>
</body>
</html>
If I try parsing the xml through simplepie again it shows the image as a podcast. Instead of that I want that image to be seen in the xml. Please tell me if I am doing it the right way or not? And if not what is the right way to do it.
Thanks