Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Try to set the content-type to make the beeminder api happy

  • Loading branch information...
commit e571be67b8bb9bea8fca6576ea7b221083353427 1 parent 6867b40
Duke Leto leto authored
Showing with 15 additions and 6 deletions.
  1. +9 −5 lib/WWW/Beeminder.pm
  2. +6 −1 t/01_basic.t
14 lib/WWW/Beeminder.pm
View
@@ -4,7 +4,7 @@ use JSON;
use WWW::Mechanize;
use namespace::autoclean;
-has base_url => ( is => 'rw', isa => 'Str', default => 'https://www.beeminder.com' );
+has base_url => ( is => 'rw', isa => 'Str', default => 'http://beta.beeminder.com' );
has username => ( is => 'rw', isa => 'Str', default => '' );
has goal => ( is => 'rw', isa => 'Str', default => '' );
@@ -25,14 +25,18 @@ sub add_data {
$self->goal,
);
+ #warn "POSTing to $post_url";
+
# specify a default origin if none was provided
- unless ($data->{origin}) {
- $data->{origin} ||= $self->username . '_api';
- }
+ $data->{origin} ||= $self->username . '_api';
my $mech = WWW::Mechanize->new;
- my $r = $mech->post( $self->base_url(), $data );
+
+ $mech->add_header('content-type' => 'application/x-www-form-urlencoded');
+
+ my $r = $mech->post( $self->base_url(), $data);
+
# crappy, but just return the LWP response for now
return $r;
7 t/01_basic.t
View
@@ -2,6 +2,7 @@
use Test::More;
use WWW::Beeminder;
+use Data::Dumper;
# This actually hits the Beeminder API. Yes mocking would be better, but
# since the Beeminder API is still in flux, not very useful.
@@ -18,8 +19,12 @@ isa_ok($bee, 'WWW::Beeminder');
my $r = $bee->add_data({
- datapoints_text => '42 82',
+ datapoints_text => '29 99',
sendmail => 0,
});
+print Dumper [ $r ];
+
+ok($r->is_success, 'got a successful response from beeminder');
+
done_testing;
Please sign in to comment.
Something went wrong with that request. Please try again.