[BNM] rss feeds

Joe Aliferis joe at newforms.co.uk
Thu Jul 23 18:00:48 BST 2009


I followed your advice and created a php script that returns an image 
when called with an id as a GET parameter

that works fine - I can test in a browser and see one jpg at a time

I then re-wrote my rss script to use this php script to load an image 
into the rss <description> element, inside the <item>

I must be doing something wrong cause it wont work !

It breaks my feed in an RSS reader - so it displays nothing

This is my php - can you any stupid mistakes?

I spent so long messing with this now I think I am error blind !

Either that or I'm just a twat...

Joe

--------------------------------------------------------------------------------------------------
mysql_select_db($database, $db_connect);

$query_rs_rss = "SELECT * FROM event WHERE `date` >= CURDATE() ORDER BY 
`date` ASC";

$rs_rss = mysql_query($query_rs_rss, $db_connect) or die(mysql_error());

$row_rs_rss = mysql_fetch_assoc($rs_rss);

$rss = "";
header("Content-Type: text/xml; UTF-8");
$rss .= "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n";
$rss .= "<rss version=\"2.0\" 
xmlns:c=\"http://base.google.com/cns/1.0\">\r\n";
$rss .= "<channel>\r\n";
$rss .= "<title>A title</title>\r\n";
$rss .= "<link>http://www.domain.com</link>\r\n";
$rss .= "<description>Upcoming events</description>\r\n";
$rss .= "<copyright>company name</copyright>\r\n";

do{
       
$itemImage = "<img 
src=\"http://www.domain.com/makeimage.php?id=".$row_rs_rss['id']."\">";
   
$rss .= "<item>\r\n";
$rss .= "<c:eventdate type=\"date\">" . $row_rs_rss['date'] . 
"</c:eventdate>\r\n";
$rss .= "<title>" . $row_rs_rss['title'] . "</title>\r\n";
$rss .= "<description>" . $itemImage .  "</description>\r\n";
$rss .= "<c:type>" . $row_rs_rss['type'] . "</c:type>\r\n";
$rss .= "</item>\r\n";
}while ($row_rs_rss = mysql_fetch_array($rs_rss));

$rss .= "</channel>\r\n";
$rss .= "</rss>\r\n";

$rawstring = $rss;

$placeholders = array("&", "!", "'", "í");

$output = array("&amp;", "&#33;", "&#39;", "&#39;");

$outputrss = str_replace($placeholders, $output, $rawstring);

echo $outputrss;

mysql_free_result($rs_rss);

--------------------------------------------------------------------------------------------------



> Yeah, totally.
> Using PHP?
>
> The biggest gotcha is to make sure that the image.php script sets the right
> Content-type header. E.g.
>
> $image_data = get_image_data_from_database_magic();
> header('Content-type: image/jpeg');
> echo $image_data;
>
> Obviously image/jpeg needs to be image/jpeg or image/png or image/gif
> depending on the format of the image.
>
> Al
>
>
> 2009/7/22 Joe Aliferis <joe at newforms.co.uk>
>
>   
>> that some sexy clever sh*t
>>
>> will it work ?
>>
>> Joe
>>
>>     
>>> A solution would be to create another script that returns an image for a
>>> given Id from the database, e.g.
>>> /image.php?image_id=3432
>>>
>>> Then in the RSS feed, you just need to insert the URLs for this new
>>>       
>> script
>>     
>>> with the image ids in place.
>>>
>>> Al
>>>
>>> 2009/7/22 Alastair James <al.james at gmail.com>
>>>
>>>
>>>       
>>>> As far as I am aware this is not possible. It *may* work on browsers
>>>>         
>> that
>>     
>>>> support the data URI scheme (
>>>>         
>> http://en.wikipedia.org/wiki/Data_URI_scheme)
>>     
>>>> but it would be far from a cross browser solution!
>>>> Al
>>>>
>>>>
>>>> 2009/7/22 Joe Aliferis <joe at newforms.co.uk>
>>>>
>>>>
>>>>         
>>>>> Not sure what you mean ?
>>>>>
>>>>> the images are stored in the DB as blob data
>>>>>
>>>>> I am trying to write a php script to output a table, that includes this
>>>>> blob field, as an RSS feed
>>>>>
>>>>> I can get everything to work but cannot work out how to include the
>>>>> image in the RSS feed
>>>>>
>>>>> Joe
>>>>>
>>>>>
>>>>>
>>>>>           
>>>>>> Joe,
>>>>>>
>>>>>> Hello. Can I ask why not just store a link to a binary image file?
>>>>>>
>>>>>> Best,
>>>>>> Andrew Gill (andrew at andrewgill.com)
>>>>>> www.ChatBadge.com
>>>>>>
>>>>>> 2009/7/22 Joe Aliferis <joe at newforms.co.uk>
>>>>>>
>>>>>>
>>>>>>
>>>>>>             
>>>>>>> Hi all
>>>>>>>
>>>>>>> does anyone know how to include binary image data from mysql database
>>>>>>> into an RSS feed ?
>>>>>>>
>>>>>>> idea is to show a thumbnail along with the text from the DB record
>>>>>>>
>>>>>>> Cheers
>>>>>>>
>>>>>>> Joe
>>>>>>> --
>>>>>>>
>>>>>>> BNM Subscribe/Unsubscribe:
>>>>>>> http://www.brightonnewmedia.org/options/bnmlist
>>>>>>>
>>>>>>> BNM powered by Wessex Networks:
>>>>>>> http://www.wessexnetworks.com
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>> --
>>>>>
>>>>> BNM Subscribe/Unsubscribe:
>>>>> http://www.brightonnewmedia.org/options/bnmlist
>>>>>
>>>>> BNM powered by Wessex Networks:
>>>>> http://www.wessexnetworks.com
>>>>>
>>>>>
>>>>>           
>>>> --
>>>> Dr Alastair James
>>>> CTO James Publishing Ltd.
>>>> http://www.linkedin.com/pub/3/914/163
>>>>
>>>> www.worldreviewer.com
>>>> WINNER Yahoo! Finds of the Year 2007
>>>> WINNER Travolution Awards Best New Online Travel Company 2008
>>>> WINNER Travel Weekly Magellan Award 2008
>>>> WINNER IRHAS Awards, Los Angeles, Best Travel Website 2008
>>>> SPECIAL MENTION: AOP Awards 2008
>>>>
>>>> "In a market increasingly crowded with new content and experience-led
>>>> sites, Worldreviewer stands out a mile. It has used exclusive
>>>> editorial and excellent tools to wonderful effect and ensured its
>>>> commercial partnerships are relevant to the target market."
>>>>
>>>> Blog: onewheeledbicycle.com
>>>>
>>>> "Noli nothis permittere te terere!"
>>>>
>>>>
>>>>         
>>>
>>>
>>>       
>> --
>>
>> BNM Subscribe/Unsubscribe:
>> http://www.brightonnewmedia.org/options/bnmlist
>>
>> BNM powered by Wessex Networks:
>> http://www.wessexnetworks.com
>>
>>     
>
>
>
>   



More information about the BNMlist mailing list. Powered by Wessex Networks