Search code examples
phppythonrsswebsubgoogle-alerts

Process notifications from Google Alert (using PubSubHubbub): PHP or Python


I have created some custom alerts using Google alerts. I have set the alerts up so that they are sent to my Google account (RSS) feed.

According to the deliver to RSS feed section, "Developers and feed readers can receive real-time updates by subscribing to the feed using the PubSubHubbub protocol. This allows applications to be notified of new alerts as they become available".

Despite trawling the net for several hours, I have not been able to find a simple example (PHP or Python) that shows how I may automatically process the feed data as it comes in.

What I'm looking for is a simple example, that will respond to the new feed message as it arrives - for example, simply log the feed message to file.

Can anyone post a simple snippet in either PHP or Python, that shows how I may get started in automating the PubSubHubbub updates that arrive on the Google alert RSS feed?


Solution

  • Subscribe your callback URL, then recieve notifications. Store the notifications to file. That's it.

    Subscribe/Unsubscribe: http://code.google.com/p/pubsubhubbub/source/browse/trunk/subscriber_clients/php/example.php

    Callback Notification Format: http://pubsubhubbub.googlecode.com/svn/trunk/pubsubhubbub-core-0.3.html#contentdistribution

    Edit:

    1 which endpoint is being referred to in the $callback_url? - is it the php function my server that will be called by the hub?

    That is not a PHP callback, it's the Subscriber Callback URL as defined in 2. Definitions. Check the pubsubhubbub documentation not the PHP documentation for that. It's part of the protocol.

    So it's not the PHP function, but the PHP script that will be called (requested via HTTP) by the hub.

    2 $feed variable, is this the url shown in the browser when I am reading my Google RSS feed?

    It's the URL of the feed (not the URL of your google feedreader). You should be able to find the feeds URL within your google feedreader however.