Upload
jason-austin
View
1.318
Download
0
Embed Size (px)
DESCRIPTION
Get schooled in the arts of RSS. Learn what RSS is, why it's useful, how to create feeds, and how to consume feeds.
Citation preview
How to RSS like a ninjaJason Austin - @jason_austin
On the agenda...
• What is RSS?
• Why should I use it?
• Creating RSS feeds
• Consuming RSS
• Tracking RSS performance
What is RSS?
• Way to share changing web content
• XML based
Why use RSS?
• Keep users up-to-date with fresh content
• Write once, use many
• Replace older subscription models
Use RSS for...
• ...blog posts!
• ...news articles
• ...forum and article comments
DO NOT use RSS for...
• ...a calendar feed
• ...a replacement for XML-based API’s
• ...static content
Types of RSS Feeds
• RSS 2.0
• RSS 1.0
• Atom
• ...lots more
RSS 2.0
• RSS 2.0 = Really Simple Syndication
• Most Popular
• Simplest
<?xml version="1.0"?><rss version="2.0"><channel> <title>Ninja Academy</title> <link>http://ninjaacademy.com/</link> <description>The source for Ninjas</description> <item> <title>Throwing Stars</title> <link>http://ninjaacademy.com/stars</link> <description>How to throw stars</description> </item> <item> <title>Tips for Sneakery</title> <link>http://ninjaacademy.com/sneakery</link> <description>Be Sneaky My Friend</description> </item></channel>
RSS 1.0
• RSS 1.0 = RDF Site Summary
• RDF = Resource Description Framework
• way of structuring metadata
• Consumption instructions are built in
<?xml version="1.0"?><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/"> <channel rdf:about="http://ninjaacademy.com/news.rss"> <title>Ninja Academy</title> <link>http://ninjaacademy.com/</link> <description>The Source For Ninjas</description> <items> <rdf:Seq> <rdf:li resource="http://ninjaacademy.com/stars/"/> <rdf:li resource="http://ninjaacademy.com/sneakery/"/> </rdf:Seq> </items> </channel> <item rdf:about="http://ninjaacademy.com/stars/"> <title>Throwing Stars</title> <link>http://ninjaacademy.com/stars/</link> <description>How to Throw Stars</description> <dc:date>2002-09-01</dc:date> </item> <item rdf:about="http://ninjaacademy.com/sneakery/"> <title>Tips for Sneakery</title> <link>http://ninjaacademy.com/sneakery/</link> <dc:date>2002-09-02</dc:date> </item></rdf:RDF>
Atom Feeds
• 2 types of Atom Specs
• Atom Syndication Format
• Atom Publishing Protocol
Atom Syndication Format
• XML based
• Used for web feeds
• Similar to RSS
Atom Publishing Protocol
• HTTP-based
• Standard for API-like services
• Used by Google’s GData APIs
Atom as a feed
• Intended to replace RSS
• Meant to clarify feed specs
• Not as widely adopted
<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom"> <title>Ninja Academy</title> <link href="http://ninjaacademy.com/"/> <updated>2003-12-13T18:30:02Z</updated> <author> <name></name> </author> <id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id> <entry> <title>Throwing Stars</title> <link href="http://ninjaacademy.com/stars/"/> <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id> <updated>2003-12-13T18:30:02Z</updated> <summary>How to throw stars.</summary> </entry> <entry> <title>Tips for Sneakery</title> <link href="http://ninjaacademy.com/sneakery/"/> <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id> <updated>2003-12-13T18:30:02Z</updated> <summary>Be Sneaky My Friend</summary> </entry></feed>
Choosing a Format
• Personal Choice
• Most syndicators can read all formats
• Don’t invent your own
Creating a feed
• Drupal, Wordpress, Joomla, etc.
• Create your own
• Lots of OSS libraries in every language
• Pretty easy to implement
<?php
$ncsu = new Tweets_Ncsu();
$timeline = $ncsu->getTimeline();
$feed = array();
$feed['title'] = ‘NC State Tweets’;$feed['link'] = ‘http://twitter.ncsu.edu/feed.php';$feed['charset'] = 'UTF-8';$feed['author'] = ‘NC State University’;$feed[‘entries’] = array(); foreach ($timeline as $t) { $feed[‘entries’][] = array( 'title' => 'Tweet by @' . $t['user-screen_name'], 'link' => 'http://www.twitter.com/' . $t['user-screen_name'], 'description' => $t['text'], 'lastUpdate' => strtotime($t['created_at']), );}
// importing a rss feed from an array$rssFeed = Zend_Feed::importArray($fa, 'rss'); // send http headers and dump the feed$rssFeed->send();
Validate your feed
• w3c’s Feed Validatorhttp://validator.w3.org/feed/
• Validates RSS 2.0 and Atom formats
Identifying RSS feeds
Finding feeds in code<!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" dir="ltr" lang="en-US">
<head>
<title>Jason Austin's Blog</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><link rel="stylesheet" href="wp-content/themes/lightword/original.css" type="text/css" /><link rel="shortcut icon" href="http://www.jasonawesome.com/favicon.ico" />
<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://www.jasonawesome.com/feed/" />
<link rel="alternate" type="text/xml" title="RSS .92" href="http://www.jasonawesome.com/feed/rss/" />
<link rel="alternate" type="application/atom+xml" title="Atom 1.0" href="http://www.jasonawesome.com/feed/atom/" />
</head>
Consuming RSS
• Browsers
• RSS Readers like Google Reader
• Programmatically
<?php
$feed = new Zend_Feed_Rss(‘http://twitter.ncsu.edu/feed.php’);
foreach ($feed as $f) { echo ‘<a href="’ . $f->link . ‘">’ . $f->title . ‘</a><br />’; echo ‘<p>’ . $f->description . ‘</p>’;}
Tracking RSS...
• Feedburner
• Subscriber stats
• Frequency stats
• AdWords integration
The End
Slides on http://www.jasonawesome.com
Jason Austin - @jason_austin