2

Pubsubhubbub hub.verify 是同步的。但它说我“尝试确认订阅时出错”。这是我的订阅代码:

<?php
if(isset($_GET["hub_challenge"])) {
exit($_GET["hub_challenge"]);;

}

$feeded = $_POST['feed']; 
$ch = curl_init("http://pubsubhubbub.appspot.com");
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch,CURLOPT_POSTFIELDS,"hub.mode=subscribe&hub.verify=sync&hub.callback=http://rssreaderbg.net/pubsubbub/example/cssexam/index1.php?url=$feeded&hub.topic=$feeded");
curl_exec($ch);
$conn = mysql_connect("localhost","rssreade_rss","siatsowi");
mysql_select_db("rssreade_rss");
?>

和我的回调代码:

if(isset($_GET["hub_challenge"])) {
    file_put_contents("logmeme1.txt",$HTTP_RAW_POST_DATA,FILE_APPEND);
exit($_GET["hub_challenge"]);

}

我的错误在哪里?

4

1 回答 1

2

规格

订阅者必须确认 hub.topic 和 hub.verify_token 对应于它希望执行的待处理订阅或取消订阅。如果是这样,订阅者必须以 HTTP 成功 (2xx) 代码进行响应,响应正文等于 hub.challenge 参数。

您可能需要明确指定 2xx 标头。这是我使用的工作代码:

if (isset($_GET['hub_challenge'])) {
    header('HTTP/1.1 204 "No Content"', true, 204);
    echo $_GET['hub_challenge'];
    exit;
}
于 2011-07-29T21:53:02.210 回答