O'Reilly logo

Programming Social Applications by Jonathan LeBlanc

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementation Overview

We’ve explored the Salmon protocol from a few different angles at this point, including an overview of its stages and how to protect against abuse and spam. Now let’s focus on what each stage of the protocol looks like from a programmatic view.

The Salmon protocol process starts when the publisher, or source, makes an update to its content and pushes the information out to all of its subscribers (through an RSS/Atom-based HTTP POST request). Within the feed, the publisher includes a Salmon link with an href value pointing to some URI endpoint on its side where it can accept Salmon requests from subscribers:

<link rel="salmon" href="http://example.org/salmon-endpoint"/>

The subscriber will process the updates from the publisher as it normally would, and will store the Salmon endpoint on its side for future use.

Once an update (e.g., a comment) has been posted to that feed, the subscriber will store the comment on its side as usual, but will then send an HTTP POST request to the Salmon endpoint on the publisher containing a Salmon version of the update:

POST /salmon-endpoint HTTP/1.1 Host: example.org Content-Type: application/atom+xml <?xml version='1.0' encoding='UTF-8'?> <me:env xmlns:me="http://salmon-protocol.org/ns/magic-env"> <me:data type='application/atom+xml'> PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0nVVRGLTgnPz4KPGVudHJ5IHhtbG5zPS dodHRwOi8vd3d3LnczLm9yZy8yMDA1L0F0b20nPgogIDxpZD50YWc6ZXhhbXBsZS5jb20s MjAwOTpjbXQtMC40NDc3NTcxODwvaWQ-ICAKICA8YXV0aG9yPjxuYW1lPnRlc3RAZXhhbX ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required