RSS Like A Ninja

28
How to RSS like a ninja Jason Austin - @jason_austin

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.

Transcript of RSS Like A Ninja

Page 1: RSS Like A Ninja

How to RSS like a ninjaJason Austin - @jason_austin

Page 2: RSS Like A Ninja

On the agenda...

• What is RSS?

• Why should I use it?

• Creating RSS feeds

• Consuming RSS

• Tracking RSS performance

Page 3: RSS Like A Ninja

What is RSS?

• Way to share changing web content

• XML based

Page 4: RSS Like A Ninja

Why use RSS?

• Keep users up-to-date with fresh content

• Write once, use many

• Replace older subscription models

Page 5: RSS Like A Ninja

Use RSS for...

• ...blog posts!

• ...news articles

• ...forum and article comments

Page 6: RSS Like A Ninja

DO NOT use RSS for...

• ...a calendar feed

• ...a replacement for XML-based API’s

• ...static content

Page 7: RSS Like A Ninja

Types of RSS Feeds

• RSS 2.0

• RSS 1.0

• Atom

• ...lots more

Page 8: RSS Like A Ninja

RSS 2.0

• RSS 2.0 = Really Simple Syndication

• Most Popular

• Simplest

Page 9: RSS Like A Ninja

<?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>

Page 10: RSS Like A Ninja

RSS 1.0

• RSS 1.0 = RDF Site Summary

• RDF = Resource Description Framework

• way of structuring metadata

• Consumption instructions are built in

Page 11: RSS Like A Ninja

<?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>

Page 12: RSS Like A Ninja

Atom Feeds

• 2 types of Atom Specs

• Atom Syndication Format

• Atom Publishing Protocol

Page 13: RSS Like A Ninja

Atom Syndication Format

• XML based

• Used for web feeds

• Similar to RSS

Page 14: RSS Like A Ninja

Atom Publishing Protocol

• HTTP-based

• Standard for API-like services

• Used by Google’s GData APIs

Page 15: RSS Like A Ninja

Atom as a feed

• Intended to replace RSS

• Meant to clarify feed specs

• Not as widely adopted

Page 16: RSS Like A Ninja

<?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>

Page 17: RSS Like A Ninja

Choosing a Format

• Personal Choice

• Most syndicators can read all formats

• Don’t invent your own

Page 18: RSS Like A Ninja

Creating a feed

• Drupal, Wordpress, Joomla, etc.

• Create your own

• Lots of OSS libraries in every language

• Pretty easy to implement

Page 19: RSS Like A Ninja

<?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();

Page 20: RSS Like A Ninja

Validate your feed

• w3c’s Feed Validatorhttp://validator.w3.org/feed/

• Validates RSS 2.0 and Atom formats

Page 21: RSS Like A Ninja

Identifying RSS feeds

Page 22: RSS Like A Ninja

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&#039;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>

Page 23: RSS Like A Ninja

Consuming RSS

• Browsers

• RSS Readers like Google Reader

• Programmatically

Page 24: RSS Like A Ninja
Page 25: RSS Like A Ninja

<?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>’;}

Page 26: RSS Like A Ninja

Tracking RSS...

• Feedburner

• Subscriber stats

• Frequency stats

• AdWords integration

Page 27: RSS Like A Ninja
Page 28: RSS Like A Ninja

The End

Slides on http://www.jasonawesome.com

Jason Austin - @jason_austin