GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing indieweb.org โ How to publish and consume WebSub (Redirected from How to publish and consume PubSubHubbub) This page is a description of a minimum viable subset of PuSH 0.4 that is sufficient for supporting the IndieWeb use cases of realtime publishing feeds of h-entry posts, and subscribing to & receiving notifications of updates from those feeds.
WhyThe PuSH 0.4 spec talks only about the relationship between subscribers and publishers. PuSH 0.4 does not specify:
This guide assumes the use cases above to provide a more concrete description of how to use PuSH. It is meant to leave as little ambiguity as possible so that implementers have a direct path to using it. OverviewHow to PublishLink to your PuSH HubConsumers will need two pieces of information in order to subscribe to your content, the hub that you send pings to, and the topic which is just the URL that contains the feed, for example your home page. If you don't yet have a hub, you should first choose one to use. Currently the most stable hub that is compatible with 0.4 and HTML resources is Superfeedr. You can use the common Superfeedr hub without any registration by using Add the two URLs in an HTTP Link header, For example, the HTTP Link headers should look like this: Link: <https://pubsubhubbub.superfeedr.com/>; rel="hub" Link: <https://kylewm.com/>; rel="self" Or as one Link: header: Link: <https://pubsubhubbub.superfeedr.com/>; rel="hub", <https://kylewm.com/>; rel="self"
<link rel="self" href="https://kylewm.com/"> <link rel="hub" href="https://pubsubhubbub.superfeedr.com/"> Notify the hub of new contentWhen you update your feed, you need to notify your hub that there is new content. Send an HTTP form-encoded POST to your hub with two fields:
The hub will check your URL for new content, then notify all subscribers of the update. Multiple topic URLsWhen a new post is created, it appears on one's home page, archives page, and often on a tag page. For example, when posting this note (http://aaronparecki.com/notes/2015/03/17/5/monocle), the following URLs were updated:
Rather than sending 5 publish pings to the hub, it is better to send a single publish request. There are currently two different ways to indicate multiple topic URLs in a single request, using array notation and with wildcards. Array NotationFor hubs that support array notation, make a request with all of the topic URLs that were updated: hub.mode=publish &hub.url[]=http://aaronparecki.com/ &hub.url[]=http://aaronparecki.com/notes &...etc This is supported by the following hubs: WildcardsFor hubs that support the wildcard method, you can use a hub.mode=publish &hub.url=http://cweiske.de/* If the hub receives a wildcard url in the publish request, it checks which subscription URLs match the wildcard URL. Those URLs are then checked for changes. This is supported by the following hubs: This is nice for static blogs. After updating the blog content, you only have to tell the hub that http://blog.example.org/* changed, and the hub figures out the rest. No need to keep track of the changed URLs the hub has been notified of. How to SubscribeDiscover the "hub" and "self" URLsGiven a URL of posts such as https://kylewm.com/, you first need to discover what hub it is using. To find the hub, first look for an HTTP To find the URL value, check for an HTTP Now you have two URLs, the "hub" and "self" URL. Send the subscription requestTo subscribe, send a form-encoded POST request to the hub with the following parameters:
The hub will reply with either The hub verifies the subscription requestAfter you send the request, the hub will make a separate request back to your callback URL to verify the request, so that attackers can't create arbitrary subscriptions for you. The request will be GET request with the following query string parameters:
To confirm the subscription, you will need to reply with To reject the request, reply with Receiving notifications of new contentNow that the subscription is created, you will begin receiving notifications at the callback URL you specified. Notifications will always be POST requests but may or may not contain a post body. The notification will also contain two Link headers with the rel=self and rel=hub URLs from the subscription. Standard NotificationsStandard notifications will not contain a POST body. As a subscriber, if you receive an empty notification, you are expected to treat this as a notification that the publisher has updated the URL, and go fetch the new content yourself. Since the page will likely be an h-feed of posts, or an h-entry with comments, there will almost certainly be content there you have already seen. You will need to properly process only the items you have not yet seen. Fat Pings"Fat ping" notifications will contain a POST body with either the full HTML of the page, or just the HTML of the new entries the publisher added since the last notification. This mechanism is likely to be used by websites with a large subscriber base, to avoid triggering thousands of subscribers making HTTP requests to the publisher's site when an update is made. The hub may parse the microformats from the publisher's website and re-create the HTML that is sent, so you should not assume the HTML is literally the same as it was from the publisher. The content will be the same of course, but it may have been reformatted if the hub parses the h-entry posts and re-generates new HTML entries from the data in the original. How to UnsubscribeSend the unsubscribe requestTo subscribe, send a form-encoded POST request to the hub with the following parameters:
The hub will reply with either The hub verifies the unsubscribe requestAfter you send the request, the hub will make a separate request back to your callback URL to verify the request, so that attackers can't remove subscriptions for you. The request will be GET request with the following query string parameters:
To confirm and unsubscribe, you will need to reply with To reject the request, reply with |
| You are visitor 01402894 โ GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800ร600. No cookies required. |