Skip to content

Instantly share code, notes, and snippets.

@mattn
Created June 3, 2009 08:16
Show Gist options
  • Save mattn/122872 to your computer and use it in GitHub Desktop.
Save mattn/122872 to your computer and use it in GitHub Desktop.
#!/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