How do I use the subscriber option?

不想你离开。 提交于 2019-12-03 07:01:13

问题


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?


回答1:


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.




回答2:


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.




回答3:


Some code that may be helpful, with good docs:

  • Zend Framework: Documentation: Zend_Feed_Pubsubhubbub - Zend Framework Manual

Example feed agregator:

  • padraic's ZFPlanet at master - GitHub


来源:https://stackoverflow.com/questions/2072591/how-do-i-use-the-subscriber-option

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!