Categories
Posts

PuSHPress: A PubSubHubbub Plugin For WordPress

PubSubHubbub, or PuSH, is now supported on all WordPress.com blogs. For those running sites using the WordPress.org software the PuSHPress plugin is available to do the same thing. The big difference in this plugin compared to the other PuSH WordPress plugins is that it includes a PuSH hub built in.

A little bit of PubSubHubbub background

Like rssCloud, PuSH adds a line to your feed to let clients know where they can send PuSH subscription requests. In the RSS2 feed this looks like:

[sourcecode lang=”xml”]
<atom:link rel="hub" href="http://josephscott.org/?pushpress=hub">
[/sourcecode]

and in Atom looks like:

[sourcecode lang=”xml”]
<link rel="hub" href="http://josephscott.org/?pushpress=hub">
[/sourcecode]

The href attribute contains the URL that subscribers can send requests to. Details on what that request looks like are in the PubSubHubbub Spec. The short version, it’s a simple HTTP POST call with some specific field names.

Here’s an example PHP subscription request asking that updates to http://example.com/feed/ be sent to http://example.com/push/ via the hub at http://example.com/?pushpress=hub

[sourcecode lang=”php”]
$curl = curl_init( );

curl_setopt( $curl, CURLOPT_URL, ‘http://example.com/?pushpress=hub’ );
curl_setopt( $curl, CURLOPT_POSTFIELDS, ‘hub.callback=http://example.com/push/&hub.mode=subscribe&hub.secret=not-telling-you&hub.verify=sync&hub.topic=http://example.com/feed/&hub.verify_token=133t-$7r1n9’ );
curl_setopt( $curl, CURLOPT_VERBOSE, 1 );
curl_setopt( $curl, CURLOPT_POST, 1 );

curl_exec( $curl );
print_r( curl_getinfo( $curl ) );
curl_close( $curl );
[/sourcecode]

The hub at example.com will then send new content (in feed format) right after it’s published to URL provided in hub.callback.

Why the PuSHPress plugin?

I love that there are large, open PuSH hubs available for anyone to use. There’s a list at http://code.google.com/p/pubsubhubbub/wiki/Hubs. In PuSH since most of the hard work (figuring out what’s new in a feed and sending that out to subscribers) is done via the hub this is very handy and really great for testing.

I also think there’s a role for a readily available simple hub that anyone can put up and use, in this case built on top of WordPress. And by leveraging WordPress the hub part can be greatly simplified. The real bonus for users is choice, they can relay the updates through 3rd party hubs, or use the built in hub in PuSHPress.

It’s worth noting that PuSHPress has a WordPress filter on the array of hubs; pushpress_hubs. This allows other plugins to easily add to or replace the hubs mentioned in the feeds by PuSHPress.

To help keep things simple and limit potential abuse the PuSHPress plugin will only allow subscriptions for the RSS2 and Atom feeds of the WordPress blog that it is installed on.

My thanks to Brett Slatkin for helping test PuSHPress. His tests revealed a few bugs that were quickly addressed.

How fast?

When talking about these realtime-ish update features this question often comes up. Fair enough, I’d want to know too 🙂

The PuSHPress plugin schedules pings to go out right away via the wp_schedule_single_event function in WordPress. I suspect for most people this will be quite fast. If your server is under tremendous load and really slow, then this will be really slow too, just like the rest of the server 😉

On WordPress.com the details are a bit different. Instead of scheduling pings to be sent out with wp_schedule_single_event it adds them to our asynchronous jobs system ( more info available at http://code.trac.wordpress.org/ ). The jobs system is setup to do exactly these kinds of tasks really, really fast. Don’t be surprised if the ping shows up before you get a chance to finish the first Mississippi.

The future

So where is all this going? Who knows, but it is fun to watch! 🙂

Further reading

If you have an interest in this area there are plenty of resources:

The spec is a quick read and to the point, worth reading.

And there you have it, a little more in-depth discussion of PuSHPress.

60 replies on “PuSHPress: A PubSubHubbub Plugin For WordPress”

Is anyone working on making the rss widget to be a client of rsscloud and PuSH whenever they are supported at the originating server of the rss feed?

Excellent question. I haven’t heard anyone mention that, but would be neat to see. Really any plugin that consumes RSS/Atom feeds could potentially benefit from having rssCloud and PuSH support.

I haven’t tried it with FeedBurner. I’d be interested to hear what happens in the feed from people using FeedBurner.

I suspect that they pass the hub element through untouched, though I haven’t confirmed that yet.

I mentioned in a few different places that what makes PuSHPress different from the other PuSH plugins available is that it has a built in hub. The plugin you linked to uses a 3rd party hub to relay updates out to subscribers. Either one will enable PuSH for your WordPress site, how exactly do that is the difference.

After we enabled the plugin on our WPMU site (sitewide activated) it seems like the hub element is just passed through for all feeds as you expected. Check it out here if you like:

http://feeds.feedburner.com/BigCityInformer

Now we need to see how feed applications use it and if it really speeds things up as compared to the usual old ping – options 🙂

Thanks
Big City News

I think I’m missing something.

Please can someone help?

I installed and activated the PuSH Press plugin. NOTHING has changed with my feeds. Even when I manually use:

http://ubuntulinuxhelp.com/?pushpress=hub

It returns an error that says:

“hub.callback is empty”

If I click the RSS icon in the address bar of the browser and select either RSS2 or Atom, it functions the way it’s always done. That is the RSS2 and Atom links do NOT look like the ones displayed in your “A little bit of PubSubHubbub background” section above.

What, if anything, have I done wrong. The installation information for the PuSH Press plugin said there was nothing to configure, just install and go.

Any help would be appreciated. Thanks!

I’m not sure why my feed isn’t passing through to feedburner then, gahhh 🙂 Since it seems to be working for others.

There were blog entries made after the plugin was added (plain WP 2.9.2, etc.)

It probably depends on if “PingShot” is enabled in FeedBurner, enabling it also enables FeedBurner’s built-in PubSubHubbub support. If you’re using FeedBurner’s features, you probably don’t want WordPress handling PubSubHubbub, it’ll prevent FeedBurner’s modifications (such as feedflairs) and tracking (subscriber count, clicks) from working properly. (WordPress will notify directly, FeedBurner won’t get a chance to process it)

Hey, it is lightning fast I would say. Feedburner used to take up to 30 minutes for a new item to be updated in the feeds properly. Now as soon as we press publish, it gets updated from the guys at Feedburner. So maximum 5 minutes and all other Feedburner – attached services are also updated.That’s so cool, thanks again for the plugin Joseph 🙂
Is there a good list available somewhere with all the services using PuSHPress for fetching?

Can the same process be used for Google sitemaps somehow? Are they using PuSHPress in any way? That would be perfect, once published directly in the index 🙂

I’m not aware of a list like that, though PuSHPress is just PubSubHubbub, so any service that supports that will work fine with PuSHPress.

I don’t know exactly what Google’s plans are, you’ll have to ask them 🙂

@Joseph Scott

THANK YOU!

I do have two questions (can you answer them?)

1) Where do I see that PuSHPress hub is listed (I cannot see it so am obviously not looking where you are)?

2) What application are you using to access the RSS feed, or how? (After your 403 error, I got worried and had several people test it; and they could all access it).

Thanks muchly again.

I tried to look through the code but could not find the answer – Does this function as a generic hub, or is it married to WordPress?

What I’d like to do is to add the wordpress hub to the rss feeds on a phpbb forum, and have the hub ping the forums often to get feed updates. PuSH defines that the hub should ping the source every interval, so this isn’t against standard use, and will be much easier than hacking a pinging mechanism into phpbb.

If you define a hub in your feed, you should probably ping it, that’s kind-of the point. Without the pings it’s not live… the point of PuSH is to send messages via a push system, not a polling system. The polling you’re talking about is to make sure the feed still exists, and, in the case of some hubs, allow a PuSH-only subscriber to subscribe to non-PuSH feeds.

In terms of which hub to use, you might consider just using an open hub, such as http://pubsubhubbub.appspot.com/, if you don’t want to implement/run your own.

When I post to pushpress (i.e. “ping” the hub, per section 7.1 of pubsubhubbub), I get a 400 Bad Request, with the body set to hub.callback is empty. The request and response are below. Any ideas?

Thanks

POST http://localhost/wordpress/?pushpress=hub HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Content-Length: 62
Cookie: wordpress_test_cookie=WP+Cookie+check; wordpress_logged_in_bbfa5b726c6b7a9cf3cda9370be3ee91=admin_wp%7C1281542756%7Cf544f2e2c569e9e86c23015e92de1268; wp-settings-time-1=1281111646; wp-settings-1=editor%3Dhtml%26m0%3Do%26m1%3Do%26m2%3Dc%26m3%3Dc%26m6%3Do
Pragma: no-cache
Cache-Control: no-cache

hub.mode=publish
hub.url=http://localhost/wordpress/?feed=atom

RESPONSE
HTTP/1.0 400 Bad Request
Date: Mon, 09 Aug 2010 16:52:42 GMT
Server: Apache/2.2.14 (Win32) PHP/5.3.1
X-Powered-By: PHP/5.3.1
Content-Length: 21
Connection: close
Content-Type: text/plain; charset=utf-8

hub.callback is empty

The PuSHPress plugin includes a hub, there is no need to manually ping a hub about updates. When you publish a new post in WordPress PuSHPress knows about it, so it can immediately turn around and send out the client pings.

If you are using PuSHPress to add PuSH support to your WP install the only thing you need to do is activate the plugin, it takes care of everything else.

First of all – awesome plugin, thanks for it.

One Question… I excluded one category from my feed with a global function $query->set(‘cat’,’-1′)

When I check my /feed everything is fine, posts of this category don’t appear. But PuSHPRess works different? When I check my Google Reader, I see these posts…
Any idea how to fix this? Thanks 🙂

There is nothing in PuSHPress currently to support excluding specific categories, it just watches for publish events and sends the data along. To address something like this right now you’ll need to hack the plugin a bit to check for that category that you want to exclude.

I used WPMU to network activate this plugin. When I posted a test post from my main domain blog I saw that Google indexed it very quickly but for my subdomain posts it was not occurring the same way. Is there anything else I need to do?

Two things that could be going on:

1- making sure that pings are being sent out ok for your other subdomain sites
2- ultimately Google is the one that decides what to do with the ping data, it may be that they only do rapid updates for certain sites, I don’t know

There is nothing specifically built it to do this. You can add some logging to the plugin that records all of the out going pings to make sure they are getting sent correctly.

Leave a Reply

Your email address will not be published. Required fields are marked *