Skip to content

Instantly share code, notes, and snippets.

@pjf
Created August 15, 2012 05:53
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 pjf/3356632 to your computer and use it in GitHub Desktop.
Save pjf/3356632 to your computer and use it in GitHub Desktop.
bmndr code
#!/usr/bin/perl -w
use 5.010;
use strict;
use warnings;
use autodie qw( :all );
use POSIX qw( strftime );
use Config::Tiny;
use WWW::Mechanize;
use JSON::Any;
my ($goal, $datapoint, $comment) = @ARGV;
unless ($datapoint =~ /^\d+$/) {
die "Usage: $0 goal datapoint [comment]\n";
}
# Get our beeminder auth token.
my $config = Config::Tiny->read("$ENV{HOME}/.rtbmrc");
$config or die "Can't read ~/.rtbmrc config file";
my $auth_token = $config->{Beeminder}{auth_token};
# User agent time.
my $mech = WWW::Mechanize->new(
autocheck => 1,
);
$comment ||= "Auto-submitted from pjf/bmndr";
$comment =~ s/"//g; # Strip quotes
$mech->post(
"http://beeminder.com/api/v1/users/pjf/goals/$goal/datapoints.json?auth_token=$auth_token",
{
timestamp => time(),
value => $datapoint,
comment => $comment
}
);
# say $mech->content;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment