0

I'm trying to post 3 pictures in tumblr via perl API ...

I have this code work good with one picture :

use LWP::Authen::OAuth;
use Data::Dumper;

my $ua = LWP::Authen::OAuth->new(
            oauth_consumer_key => 'xxx',
            oauth_consumer_secret => 'xxx',
            oauth_token => 'xxx',
            oauth_token_secret => 'xxx',
    );
my $url  = 'http://publicpics.free.fr/856833_10151249956981150_1285625380_o.jpg';
my %elements = (  
  'type' => 'photo', 
  'source' =>  $url,
);

print Dumper (\%elements);
print $ua->post( 'http://api.tumblr.com/v2/blog/xxxx.tumblr.com/post', [%elements] )->as_string;

I use this API Documentation http://www.tumblr.com/docs/en/api/v2#posting

For several pictures you must past in parameters an Array ... So i Try this but dont' work :

use LWP::Authen::OAuth;
use Data::Dumper;

my $ua = LWP::Authen::OAuth->new(
            oauth_consumer_key => 'xxx',
            oauth_consumer_secret => 'xxx',
            oauth_token => 'xxx',
            oauth_token_secret => 'xxx',
    );
my @url  = ( 'http://publicpics.free.fr/856833_10151249956981150_1285625380_o.jpg' );
my %elements = (  
  'type' => 'photo', 
  'data' =>  \@url,
);

print Dumper (\%elements);
print $ua->post( 'http://api.tumblr.com/v2/blog/xxxx.tumblr.com/post', [%elements] )->as_string;

I have this return :

$VAR1 = {
      'data' => [
                  'http://publicpics.free.fr/856833_10151249956981150_1285625380_o.jpg'
                ],
      'type' => 'photo'
    };
HTTP/1.1 400 Bad Request
Connection: close
Date: Sun, 03 Mar 2013 22:01:13 GMT
Server: Apache
Vary: Accept-Encoding
Content-Length: 92
Content-Type: application/json
Client-Date: Sun, 03 Mar 2013 22:01:13 GMT
Client-Peer: 66.6.36.55:80
Client-Response-Num: 1
P3P: CP="ALL ADM DEV PSAi COM OUR OTRo STP IND ONL"
X-Tumblr-Usec: D=112074

{"meta":{"status":400,"msg":"Bad Request"},"response":{"errors":["Error uploading photo."]}}
1
  • Thanks, but no change ! Mar 3, 2013 at 23:37

1 Answer 1

1

Data is for local file, use source for internet accessible images

my %elements = (  
  'type' => 'photo', 
  'source' =>  \@url,
);

Regards,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.