PubSubHubbabababababaでtestしてみた
PubSubHubbubです。
これの5〜11ページをやっただけ。ほんとやっただけ。
$ sudo yum -y install httpd $ sudo yum -y install mod_ssl $ sudo yum -y install php $ sudo vi /etc/php.ini (date.timezoneをAsia/Tokyoに) $ sudo service httpd start
- /var/www/html/subscriber.phpをsudo で vi
<?php $method = $_SERVER['REQUEST_METHOD']; // subscribe (or unsubscribe) a feed from the HUB if ($method == 'GET') { $hubmode = $_REQUEST['hub_mode']; $hubchallenge = $_REQUEST['hub_challenge']; if ($hubmode == 'subscribe' || $hubmode == 'unsubscribe') { // response a challenge code to the HUB header('HTTP/1.1 200 "OK"', null, 200); header('Content-Type: text/plain'); echo $hubchallenge; } else { header('HTTP/1.1 404 "Not Found"', null, 404); } } // receive a feed from the HUB if ($method == 'POST') { // feed Receive $string = file_get_contents("php://input"); // feed save $fp = fopen(date('YmdHis') . "_atom" . ".xml", "w"); fwrite($fp, $string); fclose($fp); }
- おもむろにsudo chown -R apache:apache /var/www/html
- http://pubsubhubbub.appspot.com/subscribeで購読設定します
CallBackにhttp://[instanceのIPアドレス]/subscriber.php Topicになんかのrss(私だったら[http://bhind.hatenablog.com/feed]) ModeはSubscribe(デフォルト) Do It!
- こんなログがきたーよ
XXX.XXX.XXX.XXX - - [06/Apr/2015:11:20:16 +0000] "GET /subscriber.php?hub.topic=http://bhind.hatenablog.com/feed&hub.challenge=9939030103204696605&hub.mode=subscribe&hub.lease_seconds=432000 HTTP/1.1" 200 19 "-" "AppEngine-Google; (+http://code.google.com/appengine; appid: s~pubsubhubbub-hrd)"
- feedを更新するーよ。そしたらこんなログがきたーよ。
YYY.YYY.YYY.YYY - - [06/Apr/2015:11:28:52 +0000] "POST /subscriber.php HTTP/1.1" 200 - "-" "FeedFetcher-Google; (+http://www.google.com/feedfetcher.html)"
<?xml version='1.0' encoding='UTF-8'?> <feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ja"><title>月が綺麗かどうか は置いといていますぐ君に会いたい、とつぶやきながらingressしに行くブログ</title>< link href="http://bhind.hatenablog.com/"/><updated>2015-04-06T20:28:48+09:00</up dated><author> <name>bhind</name> </author><generator uri="http://blog.hatena.ne.jp/" version="15f1c4ecb833ff1d2 1203882ed92939c">Hatena::Blog</generator><id>hatenablog://blog/12921228815724923 531</id><entry> <title>test2</title> <link href="http://bhind.hatenablog.com/entry/2015/04/06/202847"/> <id>hatenablog://entry/8454420450090602806</id> <published>2015-04-06T20:28:47+09:00</published> <updated>2015-04-06T20:28:47+09:00</updated> <summary type="html">test2</summary> <content type="html"><p>test2</p> </content> <author> <name>bhind</name> </author> </entry></feed>
- おわりーよ