Pubsubhubbub subscriber problem
Pubsubhubbub hub.verify is sync. But it says me "Error trying to confirm subs开发者_StackOverflowcription". Here's my subscribe code:
<?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");
?>
and my callback code:
if(isset($_GET["hub_challenge"])) {
file_put_contents("logmeme1.txt",$HTTP_RAW_POST_DATA,FILE_APPEND);
exit($_GET["hub_challenge"]);
}
Where's my error?
From the spec:
The subscriber MUST confirm that the hub.topic and hub.verify_token correspond to a pending subscription or unsubscription that it wishes to carry out. If so, the subscriber MUST respond with an HTTP success (2xx) code with a response body equal to the hub.challenge parameter.
You may need to explicitly specify a 2xx header. This is the working code I use:
if (isset($_GET['hub_challenge'])) {
header('HTTP/1.1 204 "No Content"', true, 204);
echo $_GET['hub_challenge'];
exit;
}
精彩评论