コードだけ。
#!/usr/bin/perl
use strict;
use warnings;
use Encode;
use LWP::UserAgent;
use HTTP::Request::Common qw(POST);
use Config::Pit;
use Digest::SHA1 qw(sha1_hex);
use JSON;
if ($^O eq 'MSWin32') {
eval {
require Win32::API;
Win32::API->Import('kernel32', 'UINT GetACP()');
Encode::from_to($ARGV[0], 'cp'.GetACP(), 'utf-8');
};
}
my $config = pit_get("im.kayac.com", require => {
"username" => "your username on im.kayac.com",
"password" => "your password(or secretkey) on im.kayac.com",
"authtype" => "auth type on im.kayac.com: none/password/secretkey",
});
my %data = ( message => shift );
die "should be specify message" unless $data{message};
$data{password} = $config->{password} if $config->{authtype} eq "password";
$data{sig} = sha1_hex($data{message} . $config->{password}) if $config->{authtype} eq "secretkey";
my $ua = LWP::UserAgent->new;
my $res = from_json($ua->post(
"http://im.kayac.com/api/post/$config->{username}", \%data,
"Content-Type" => "application/x-www-form-urlencoded"
)->decoded_content);
print $res->{result}.$res->{error};