Created
June 3, 2009 08:16
-
-
Save mattn/122872 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use utf8; | |
use CGI; # qw/-utf8/; | |
use DateTime::Format::W3CDTF; | |
use WebService::Simple; | |
use WebService::Simple::Parser::JSON; | |
use YAML; | |
my $req = CGI->new; | |
# キーの比較 | |
if ( ( $req->param('key') || '' ) ne 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' ) { | |
die "Authentication failed"; | |
} | |
# エントリーの情報 | |
my $url = $req->param('url'); | |
my $title = $req->param('titile'); | |
my $comment = $req->param('comment'); | |
# ここに好きな処理を実装する | |
my $wassr = WebService::Simple->new( | |
response_parser => WebService::Simple::Parser::JSON->new, | |
base_url => "http://api.wassr.jp/", | |
param => {} | |
); | |
$wassr->credentials( 'api.wassr.jp:80', 'API Authentication', | |
'your-name', 'your-password', ); | |
my $response = | |
$wassr->post( '/statuses/update.json', | |
# { status => "$comment > $title : $url" } ); | |
{ status => "はてブった : $url" } ); | |
my $res = $response->parse_response(); | |
print header('text/plain'); | |
if ( $res->{error} ) { | |
print "ng"; | |
} | |
else { | |
print 'ok'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment