2011-03-02 39 views
1

Pubsubhubbub hub.verify is sync。 但它说我“错误尝试确认订阅”。 这里是我的订阅代码:Pubsubhubbub用户问题

<?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"]); 

} 

哪里是我的错误?

回答

1

the spec

订户必须确认hub.topic和hub.verify_token对应于未决的订阅或取消订阅其希望进行。如果是这样,用户必须用响应主体等于hub.challenge参数的HTTP成功(2xx)代码进行响应。

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

if (isset($_GET['hub_challenge'])) { 
    header('HTTP/1.1 204 "No Content"', true, 204); 
    echo $_GET['hub_challenge']; 
    exit; 
}