我尝试了超过10个小时来建立一个Google的pubsubhubbub提要(手动+ php),但是它不起作用。以下是我迄今所做的工作:
- Callback URL: [http://buystream.me/endpoint.php](http://buystream.me/endpoint.php)
- Topic URL: [http://buystreamme.blogspot.de/feeds/posts/default](http://buystreamme.blogspot.de/feeds/posts/default)
- Verify type: Asynchronous
- Mode: Subscribe
- No Verify Token, HMAC Secret and Lease Seconds
我的endpoint.php看起来是这样的:
<?php
if (isset($_GET['hub_challenge'])) {
file_put_contents('verification.txt',"verified");
header('HTTP/1.1 204 "No Content"', true, 204);
echo $_GET['hub_challenge'];
exit;
}
else {
$xml=file_get_contents("php://input");
file_put_contents('endpoint.txt',$xml);
}
?>发生什么事了?
我做错了什么?
希望有人能帮我。我看不出错误和其他搜索结果对我没有帮助:
非常感谢,
托马斯
发布于 2013-09-26 00:59:07
9个小时后我找到了答案..。所以如果有人有类似的问题,我想和大家分享一下我的想法:
看完这篇文章后
https://groups.google.com/d/msg/pubsubhubbub/7RPlYMds4RI/2mIHQTdV3aoJ
很明显,我必须输入一些(int)号作为租赁秒,并删除所有的验证令牌。此外,由于“同步”已过时,用于“同步”的409的错误返回HTTP代码“验证类型”现在是明确的。
总之,我认为https://pubsubhubbub.appspot.com/subscribe已经过时了。
My解决方案:
<?
$secret = hash('sha1', uniqid(rand(), true));
$post_fields = array(
'hub.callback' => 'some_php_callback_file_on_your_webspace',
'hub.mode' => 'subscribe',
'hub.topic' => 'your_feed', // must be equal to "self" href in feed!
'hub.verify' => 'async',
'hub.lease_seconds' => '300', //5 minutes subscription, than feed expires
'hub.secret' => $secret
);
$request = curl_init('https://pubsubhubbub.appspot.com/'); // the hub
curl_setopt($request, CURLOPT_POST, TRUE);
curl_setopt($request, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt( $request, CURLOPT_VERBOSE, 1 );
curl_exec($request);
$code = curl_getinfo($request, CURLINFO_HTTP_CODE);
print_r( $code );
if (in_array($code, array(202, 204))) {
print_r("Positive response - request ($code). - secret: $secret");
}
else {
print_r("Error issuing - request - ($code).");
}
curl_close($request);
?>我的callback.php文件:
if (isset($_GET['hub_challenge'])) {
print $_GET['hub_challenge'];
}
else {
$xml=file_get_contents("php://input");
file_put_contents('endpoint.txt',$xml);
}当然不是最终的解决方案,但我很高兴两天后的第一稿:)
https://stackoverflow.com/questions/19008003
复制相似问题