10

I started now with Pubsubhubbub (and all about realtime things), but I amhaving trouble with the Subscriber option.

I'm trying to develop a webapp in PHP to:

  1. Subscribe a RSS (previously Published) to the Hub (http://pubsubhubbub.appspot.com/);
  2. Read notifications (updates) from the Hub for the subscription; without succeed!!! :(

I verify that exist a library in php to the Subscriber (in Git), but using this lib can't make the Subscribe work's (get a 409 error!).

How can I do this?

durron597
  • 31,968
  • 17
  • 99
  • 158
ddluis
  • 101
  • 1
  • 5
  • A 409 error is a *conflict* and - in pubsubhubbub - occurs when subscription verification fails – Adam Hopkinson Jan 15 '10 at 15:27
  • OK , I opened the bounty ,but I can't edit @ddluis 's question ,so I am going to ask here. And how exactly to implement this - http://github.com/lxbarth/PuSHSubscriber/ class?I don't get this part:Integration with host applications –  Oct 06 '10 at 08:26

3 Answers3

3

This is an old question and the PHP library ddluis linked to has many flaws.

The recommended PHP subscriber in the Google Code wiki is PuSHSubscriber:

http://github.com/lxbarth/PuSHSubscriber/

UPDATE:

I forked PuSHSubscriber: http://github.com/bobdia/PuSHSubscriber

I've made a few incompatible changes with the original. A simple implementation can be found in the /example directory. This is not meant for real use, just for demonstration purposes. I hope you find it useful.

bobdiaes
  • 1,120
  • 11
  • 9
  • And why not http://pubsubhubbub.googlecode.com/svn/trunk/subscriber_clients/php/subscriber.php ? It simpler! –  Oct 06 '10 at 08:18
  • And how exactly to implement the above class?I don't get this part:Integration with host applications –  Oct 06 '10 at 08:21
  • 2
    The php class that the OP linked to seems simpler because it doesn't really do much. PuSHSubscriber is quite simple and does everything you need except storing the notifications it receives. I decided to make an example implementation with it, so check back in a day or two and I'll post a link to something everyone can easily understand. – bobdiaes Oct 06 '10 at 12:13
  • So ,what exactly SubscriptionInterface and EnvironmentInterface have to implement? –  Oct 09 '10 at 16:50
  • What happened @bobdiaes ? What's your progress? –  Oct 10 '10 at 15:05
  • I found the interfaces - they are at the end of the script! –  Oct 11 '10 at 08:35
  • I've updated my answer with links to the example implementation. Enjoy! – bobdiaes Oct 19 '10 at 16:16
  • Hmm , it doesn't log anything in notifications.log. I use PubSubHubbub plugin for wordpress and I use and my own blog to try this ,but it don't work. In system.log:Positive response to "subscribe" request –  Oct 22 '10 at 17:05
3

The first thing I'd try is forget about libraries and try to understand what's happening in the context of a subscriber exactly. It should be really really straightforward to build a script that handles all this together.

A subscriber application must do 2 things :

  • Acknowledge the susbcription : the hub will verify the intent of the susbcriber. It's a GET request
  • Deal with incoming pings. It's a POST request.

So let's start :

  1. Put a script somewhere on the web (it must be accessible from behind a firewall) which must be bale to handle to GET requests from the hub. Make sure it only echoes the hub.challenge param that it gets in the response's body and returns 200.
  2. Send the following from your command line : curl -X POST http://pubsubhubbub.appspot.com/ -d'hub.mode=subscribe' -d'hub.verify=sync' -d'hub.topic=http://the.feed.url' -d'hub.callback=http://the.script.url' -D-
  3. You should see an incoming verification request on the script. Ideally (if you followed step 1, it should echo the hub.challenge and return a 200.

If this was all fine the curl request that you send should tell you that the hub returned a 204. If you get anything else, check the body of the response, it will indicate you what went wrong.

Later...

  1. Your script will get a POST request. This is a notification of new content!
  2. Parse the raw body (XML) of this POST request, it contains the feed, only with the new entries.
  3. Do whatever needs to be done with the parsed content (save into a database... etc).

I hope this helps. You can also use this tool to debug your subscription of you need help.

Julien Genestoux
  • 31,046
  • 20
  • 66
  • 93
  • I don't get part 1. "which must be bale to handle to GET requests from the hub" Do I have anything that I need to do with PHP here? And how to "Parse the raw body (XML) of this POST request, it contains the feed, only with the new entries. " - with simpleXML? –  Oct 20 '10 at 09:36
  • Well, the hub will perform HTTP GET request to your script, so this script must be "accessible" from the web. – Julien Genestoux Oct 20 '10 at 10:19
  • And yes, you can use simpleXML to parse the body of the POST request. – Julien Genestoux Oct 20 '10 at 10:20
1

Some code that may be helpful, with good docs:

Example feed agregator:

takeshin
  • 49,108
  • 32
  • 120
  • 164