如何使用订阅者选项?

发布于 2024-08-17 14:57:18 字数 460 浏览 4 评论 0原文

我现在开始使用 Pubsubhubbub (以及所有关于实时的东西),但我在订阅者选项方面遇到了麻烦。

我正在尝试用 PHP 开发一个 web 应用程序来:

  1. 订阅 RSS(之前发布的)到 Hub (http:// pubsubhubbub.appspot.com/);
  2. 从订阅中心读取通知(更新); 没有成功! :(

我验证php 到订阅者中存在一个库(在git),但是 使用此库无法使订阅工作(出现 409 错误!)。

我该怎么做?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

北城挽邺 2024-08-24 14:57:18

我尝试的第一件事就是忘记库,并尝试准确理解订阅者上下文中发生的情况。构建一个同时处理所有这些的脚本应该非常非常简单。

订阅者应用程序必须做两件事:

  • 确认订阅:集线器将验证订阅者的意图。这是一个
  • 处理传入 ping 的 GET 请求。这是一个 POST 请求。

那么让我们开始吧:

  1. 将一个脚本放在网络上的某个位置(它必须可以从防火墙后面访问),该脚本必须能够处理来自集线器的 GET 请求。确保它回显响应正文中获取的 hub.challenge 参数并返回 200。
  2. 从命令行发送以下内容: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. 您应该看到传入的对脚本的验证请求。理想情况下(如果您遵循步骤 1,它应该回显 hub.challenge 并返回 200。

如果一切正常,您发送的卷曲请求应该告诉您集线器返回了 204。如果您收到其他任何信息,请检查正文 。

稍后...

  1. 您的脚本将收到一个新内容的通知!
  2. 解析此 POST 请求的原始正文 (XML),它仅包含提要 对新条目
  3. 进行任何需要对解析的内容进行的操作(保存到数据库中......等),

我希望这对您有帮助。 rel="nofollow">还可以使用此工具来调试您需要帮助的订阅。

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.

み格子的夏天 2024-08-24 14:57:18

这是一个老问题,并且 ddluis 链接的 PHP 库有很多缺陷。

Google 代码 wiki 中推荐的 PHP 订阅者是 PuSHSubscriber:

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

更新:

我分叉了 PuSHSubscriber:http://github.com/bobdia/PuSHSubscriber< /a>

我做了一些与原始版本不兼容的更改。可以在 /example 目录中找到一个简单的实现。这并不意味着实际使用,仅用于演示目的。我希望你觉得它有用。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文