【发布时间】:2013-06-22 19:45:39
【问题描述】:
我正在尝试使用 PSHB 协议来接收有关我的 Google 警报的通知。我正在使用找到的代码here。但是,我不清楚如何实现回调(或端点)。
谁能提供一个简单的例子来说明我如何访问已发布到我的端点的数据?
google 代码的一个(稍作修改)sn-p 如下:
<?php
// simple example for the PHP pubsubhubbub Subscriber
// as defined at http://code.google.com/p/pubsubhubbub/
// written by Josh Fraser | joshfraser.com | josh@eventvue.com
// Released under Apache License 2.0
include("subscriber.php");
$hub_url = "http://pubsubhubbub.appspot.com";
$callback_url = "http://www.example.com/mycallback.php"; // <- how to implement this ?
[[编辑]]
我在下面添加了一些伪代码,以帮助进一步澄清问题...
// Implementation of mycallback.php
<?php
$pubsub_post_vars = $_POST[WHAT_NAME_AM_I_LOOKING_FOR]; //what's the name of the POST var?
// How do I get to the 'good stuff?
$feed_id = $pubsub_post_vars[SOME_VARIABLE]
$feed_title = $pubsub_post_vars[ANOTHER_VARIABLE]
$contents = $pubsub_post_vars[YET_ANOTHER_VARIABLE]
$author = $pubsub_post_vars[YET_ANOTHER_VARIABLE_1]
$perma_link = $pubsub_post_vars[YET_ANOTHER_VARIABLE_2]
$pub_date = $pubsub_post_vars[YET_ANOTHER_VARIABLE_3]
?>
我意识到这种方法(上图)可能完全错误,因为我怀疑它是 POST 的 RSS/ATOM 文档。但是,像上面这样的一些骨架代码应该足以让我开始,这样我就可以提取提要 ID、标题和发布的内容......等等。
【问题讨论】:
-
您找到解决方案了吗?你介意与我分享吗?我对回调实现也有问题。非常感谢,非常感谢您的帮助。