Skip to content

Instantly share code, notes, and snippets.

@kga
Created March 2, 2009 22:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kga/73033 to your computer and use it in GitHub Desktop.
Save kga/73033 to your computer and use it in GitHub Desktop.
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