2010-10-23 119 views
1

我用这个代码:PubSubHubbub通讯错误,确认认购

<?php 
if(isset($_GET["hub_challenge"])) { 
echo $_GET["hub_challenge"]; 
} 
else { 

} 
$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/index.php&hub.topic=http://rssreaderbg.net/blog/?feed=comments-rss2"); 
curl_exec($ch); 

file_put_contents("logmeme.txt",$HTTP_RAW_POST_DATA); 


?><?php 
if(isset($_GET["hub_challenge"])) { 
echo $_GET["hub_challenge"]; 
} 
else { 

} 
$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/index.php&hub.topic=http://rssreaderbg.net/blog/?feed=comments-rss2"); 
curl_exec($ch); 

file_put_contents("logmeme.txt",$HTTP_RAW_POST_DATA); 


?> 

但在pubsubhubbub.appspot.com轮毂给了我“错误试图确认订阅”,为什么呢?

回答

2

最简单的解决方案是尝试自己执行一个验证验证。 发送一个GET请求到你的回调中,参数为explained in the spec。确保您的回拨返回2XX,并且只回应集线器提供的hub.challenge

+0

我改变类型为异步,它的工作原理! – lam3r4370 2010-10-23 10:27:01

+0

有一些延迟,我没​​有注意到。现在它工作。谢谢! – lam3r4370 2010-10-23 10:53:28