2011-03-02 36 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; 
}