Bug patch, an error didnt get turned into an exception .... left all the tracing in there it can't really hurt :D

sub Imgur::API::request { package Imgur::API; { my ($this,$path,$method,$params) = @_; $params->{_format}="json"; $this->ua->agent("Imgur::API/0.0,1"); my $auth; if ($this->access_token) { $auth="Bearer ".$this->access_token; } else { $auth="Client-ID ".$this->client_id; } say STDERR $auth; my $response; if ($method=~/(?:post|put)/) { $response = $this->ua->$method($path,$params,'Authorization'=> +$auth); } else { $response = $this->ua->$method($path,'Authorization'=>$auth); } say Dumper($response); if ($response->content_type eq "application/json") { $this->stats->update($response); my $json = JSON::XS::decode_json($response->decoded_content); if (!$json->{success}) { my $e = Imgur::API::Exception->new(code=>$json->{status}, +message=>$json->{data}->{error}); say Dumper($json); say "BUG!!\n"; return $e; } return Imgur::API::Response->new($json); } else { return Imgur::API::Exception->new(code=>$response->code,messag +e=>$response->status_line); } }

And then this works to upload anonymously provided you've registered as documented ... for all the Moose in the code its not used for much but it might be early :/

#!/usr/bin/perl -- use strict; use warnings; use Imgur::API; use Data::Dump qw/ dd /; use Carp::Always; use feature 'say'; my $key = shift or die "key"; my $file = shift or die "folder/folder/file"; my $imgur = Imgur::API->new( client_id => $key ); dd( $imgur ); my $img = $imgur->image->upload( image => $imgur->content( $file ), title => $file, description => $file, # album => "my files 1", ## ??? folder/folder/ ???? ### No album wa +s found with the ID: my files 1 ); dd( $img ); winOrDie( $img ) or die; print join "\n", $file, bblinkimg( $img ), "\n"; print join "\n", $file, dellink( $img ), "\n"; my $ret = $imgur->image->delete( image => $img->{deletehash} ); winOrDie( $ret ) or die; exit( 0 ); sub winOrDie { my( $res ) = @_; if( $res->is_success ){ say "win winOrDie"; dd( $res ); return $res; } else { die "die winOrDie ", Data::Dump::pp( $res ); } } sub bblinkimg { my( $img ) = @_; return sprintf '[url="%s"][img]htttp://i.imgur.com/%sl.jpg[/img][/url]', $img->{link}, $img->{id}, ; } sub dellink { my( $img ) = @_; return sprintf '# https://imgur.com/delete/%s', $img->{deletehash}, $img->{id}, ; }

In reply to Re^5: Upload image to Imgur and retrieve the link/embed bbcode by Anonymous Monk
in thread Upload image to Imgur and retrieve the link/embed bbcode by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.