server-webapi-code-04-store.php / php
<?php include("../common_db.php"); switch (url = "http://example.preinheimer.com/store/index.php";\ %Y-\ %c-\ %dT\ %H:\ %i:\ %S-04:00') as pubDate FROM 03_store_tips ORDER BY pubDate"; tips = getAssoc(<?xml version="1.0" encoding="utf-8"?> <feed version="0.3" xmlns="http://purl.org/atom/ns#"> <title>Tom�s Garden Shed</title> <link rel="alternate" type="text/html" href="http://example.preinheimer.com/store/index.php" /> <modified><?php echo tips[0]['pubDate'] ?></modified> <author> <name>Tom's Garden Shed</name> </author> <?php foreach(item) { if (strlen(item['tipTrim'] = substr(item['tipTrim'] = <entry>\n"; echo "<title>{item['subject']}</title>"; echo "<link rel=\"alternate\" type=\"text/html\" href=\"item['id']}\" />"; echo "<id>item['id']}</id>"; echo "<summary>{</summary>\n"; echo "<content>{item['tip']}</content>"; echo "<issued>{</issued>"; echo "<modified>{item['pubDate']}</modified>"; echo "</entry>\n"; } echo "</feed>"; } function displayRSS() { header("Content-Type: text/xml");\ %a,\ %d\ %b\ %Y\ %T EST') as pubDate FROM 03_store_tips ORDER BY pubDate"; tips = getAssoc(<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"> <channel> <language>en</language> <title>Tom's Garden Shed, Weekly Tips</title> <description>Weekly gardening tips from Tom</description> <generator>Tom's Feed Generator, v0.01b</generator> <ttl>1440</ttl> Notice the content XML namespace, this allows us to include the entire post, not just a summary within the feed. I�ve also included the TTL declaration in this script, aggregators should notice this and refresh the feed only once a week. You could also look into the skipDays and skipHours elements to further define this more clearly. <pubDate><?php echo tips[0]['pubDate'] ?></pubDate> <link>example.preinheimer.com/store/<image> <title>Tom's Garden Shed</title> <link>example.preinheimer.com/store/<url>example.preinheimer.com/store/tom.png</image><?php foreach(item) { item['tip']) > 252) { item['tip'], 0, 252) . "..."; }else { item['tip']; } echo "<item>\n"; echo "<title>{</title>\n"; echo "<link>url?item={</link>\n"; echo "<description>{item['tipTrim']}</description>\n"; echo "<content:encoded>{</content:encoded>"; echo "<author>{item['email']}</author>\n"; echo "<pubDate>{</pubDate>\n"; echo "</item>\n"; } echo "</channel>\n</rss>"; } ?>
(C) Æliens 20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.