ã¹ã¿ã¼ãã¤ãã¨å¬ããã§ããéæ»ã§ç¥ãããã§ãããããããªæ㯠スター受け取り通知に対応した はてなブックマーク Web Hook 㨠im.kayac.com ã使ã£ã¦ IM ã«éç¥ãã¾ããããã¨ãããã¾ã§æ¸ãã¦ããé£æããããããã¨ã²ã©ããã¨ã«ãªã£ãããããããã¯ã¦ãªã¡ãã»ã¼ã¸ã¨åããããªãã®*1ã¨ãæ°ã¥ãã¾ããã
#!/usr/bin/env perl use strict; use warnings; use CGI qw/-utf8/; use CGI::Carp qw/fatalsToBrowser/; use DateTime::Format::W3CDTF; use LWP::UserAgent; use HTTP::Request::Common; use utf8; my $q = CGI->new; my $key = 'your-key-goes-here'; die 'authentication failed' if $q->param('key') ne $key; die 'only for star' if $q->param('status') ne 'star'; my $username = $q->param('username'); my $title = $q->param('title'); my $url = $q->param('url'); my $color = $q->param('color'); my $quote = $q->param('quote'); my $dt = DateTime::Format::W3CDTF->parse_datetime($q->param('timestamp'))->datetime; my $msg = sprintf 'id:%s ã %s ã«ã%s (%s)ãã¨ããã¨ã³ããªã®ã³ã¡ã³ãã«%sã¹ã¿ã¼ãã¤ããã!', $username, $dt, $title, $url, $color; $msg .= "\nå¼ç¨æã$quoteã" if $quote; LWP::UserAgent->new->request(POST 'http://im.kayac.com/api/post/your-username', [message => $msg]); print $q->header(-type => 'text/plain'), 'OK';
*1:ã¡ãã»ã¼ã¸ã® IM éç¥ã£ã¦ãªã¢ã«ã¿ã¤ã ã«æ¥ããã ã£ã?