On Tue Aug 17 17:39:40 2010, SIMONW wrote:
Show quoted text> On Tue Aug 17 17:18:51 2010, OALDERS wrote:
> > I'm currently using this module to connect to the FreshBooks.com
> API.
> > They, for whatever reason, are insisting on POST requests in some
> cases
> > where GET is hard coded into the module.
> >
> > Specifically, FreshBooks requires POST for the access and request
> > tokens. In order to make this work, POST also needs to be allowed
> for
> > in _make_request at line 719:
> >
> > if ('GET' eq $method || 'PUT' eq $method) {
>
> Notice that just after that line there's an 'else' statement.
True, but in the case of POST, it's not doing what I need it to do. In
my case, I'm overriding request_request_token(). The only change I've
made is to use POST rather than GET. If I don't include POST in the IF
statement, I get:
POST on
https://netfreshbooksapi.freshbooks.com/oauth/oauth_request.php
failed: 400 Bad Request Missing required parameter: oauth_consumer_key
If I add POST to the if condition, it works beautifully.
Show quoted text>
> You can make restricted POST requests by Just calling
> make_restricted_request with a 'POST'
> param. For example in Net::FireEagle the method 'update_location' does
>
>
> sub update_location {
> my $self = shift;
> my $location = shift;
> my %opts = @_;
>
> my %extras = $self->_munge('address', $location);
>
> my $url = $UPDATE_API_URL;
> $url .= '.'.$opts{format} if defined $opts{format};
>
> return $self->make_restricted_request($url, 'POST', %extras);
> }
>
Thanks -- that's a good example. It's just that the issues I'm seeing
are *before* I have all of the tokens. My total changes are:
adding POST to the if condition in _make_request and changing GET to
POST in request_request_token() and request_access_token()
So, that works for me and it's actually a solution that (I think) I can
live with, but it really duplicates a lot of code that I'm not sure I
want as baggage in case the internals of Net::OAuth::Simple change in
future.
This could maybe be fixed with accessors like
request_access_token_method() and request_request_token_method() which
would accept GET or POST. Those are ugly names, but off the top of my
head something along those lines might work?
Basically, just a little bit of flexibility around GET and POST would go
a long way, I think.
Best,
Olaf