Skip to content

Instantly share code, notes, and snippets.

@kga
Created Mar 2, 2009
Embed
What would you like to do?
ldr2graph
#!/usr/bin/env perl
use strict;
use warnings;
use Config::Pit qw/pit_get/;
use LWP::Simple qw//;
use List::Util qw/sum/;
use WebService::Hatena::Graph;
my $hatena_id = 'KGA';
my $ldr_api = 'http://rpc.reader.livedoor.com/count?feedlink=';
my @feeds = map { "http://d.hatena.ne.jp/$hatena_id/$_" } qw/rss rss2/;
my $conf = pit_get('hatena.ne.jp', require => {
username => 'Hatena ID',
password => 'Password',
});
my $graph = WebService::Hatena::Graph->new(%$conf);
my $total = sum map { LWP::Simple::get("$ldr_api$_") } @feeds;
$graph->post_data(
graphname => "LDR$hatena_id",
value => $total,
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment