Clone wiki

djpubsubhubbub / SuperFeedr_Tutorial

SuperFeedr Tutorial

This is a quick guide to help you get this app up and running with your SuperFeedr account.


If you have not yet installed the djpubsubhubbub app, please follow the Installation instructions and come back to this tutorial.


You're going to need to add the following settings to your projects file.

SUPERFEEDR_USER = 'your-user-name'
SUPERFEEDR_PASS = 'your-password'

# djpubsubhubbub
PUBSUBHUBBUB_CONFIG = 'myproject.config.SubHubConfig'

The above snippet is assuming your project is named 'myproject'. The first 3 variables should be obvious enough. The 4th is going to be a configuration class that the djpubsubhubbub app is going to use to talk with SuperFeedr. Continue to the next section...


The setting PUBSUBHUBBUB_CONFIG is referencing a Python path of myproject.config.SubHubConfig. We need to create a file named in your myproject directory. It should contain the following:

import base64
from django.conf import settings

class SubHubConfig(object):
    def get_extra_hub_headers(self, feed_url, hub_url):
        headers = {}
        if hub_url == settings.SUPERFEEDR_HUB:
            headers['Authorization'] = \
                'Basic %s' % base64.b64encode('%s:%s' % (
        return headers

    def get_default_callback_host(self, feed_url, hub_url):
        return ''

This will tell the djpubsubhubbub app that whenever it's talking to the SuperFeedr Hub URL, to add the authorization headers to the request, which is required by SuperFeedr.

Note: The second method above (get_default_callback_host) is optional and only necessary if you don't want to use the Django sites framework. By default, if this method is not provided, djpubsubhubbub will simply call Site.objects.get_current() to get the current FQDN to use in the callback URL. For more info, see Django Sites Documentation.


The djpubsubhubbub app uses Django signals to let you know when new content has been posted. The signal name is updated. How to use signals is beyond the scope of this tutorial, but you can read the documentation here: Django Signals.

Here is a generic example:

from djpubsubhubbub.signals import updated

def update_handler(sender, update, **kwargs):
    ''' Process new content being provided from SuperFeedr
    for entry in update.entries:
        # do something with entry here

updated.connect(update_handler, dispatch_uid='superfeedr')


You should be all setup now. You can subscribe to a new feed like so:

>>> from django.conf import settings
>>> from djpubsubhubbub.models import Subscription
>>> sub = Subscription.objects.subscribe(
...     topic='',
...     hub=settings.SUPERFEEDR_HUB,
... )

All Done!

That's pretty much it. You should now have an active subscription using SuperFeedr as a hub.

If you notice any issues with this page, please use the issue tracker above to report it and I will correct what needs to be corrected. Enjoy!