Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re^5: raw image data?

by kwaping (Priest)
on Apr 21, 2009 at 19:11 UTC ( #759088=note: print w/replies, xml ) Need Help??

in reply to Re^4: raw image data?
in thread raw image data?

Please post your code, and a dump of the results from get_error() after a failed image upload attempt.

It's all fine and dandy until someone has to look at the code.

Replies are listed 'Best First'.
Re^6: raw image data?
by 23skiddoo (Beadle) on Apr 21, 2009 at 22:19 UTC
    Here is my test code. "foo.png" is a 323KB file in the cwd.
    #!/usr/bin/perl -w use strict; use Net::Twitter; $\ = "\n"; my $img = "foo.png"; # Translate image to a raw format my $raw = do { open ( my $fh, '<:raw:perlio', $img ) or die "Can't open image file $img: $!"; local $/; <$fh>; }; # Create a connection to twitter my $twit = Net::Twitter->new( { username => "fake_uid", password => "fake_pwd", } ); # Post the image file $twit->update_profile_image( $raw ); # Grab the error hash ref and roll through it my $err = $twit->get_error; foreach my $key ( sort keys %{ $err } ) { print STDERR "$key => $err->{ $key }"; }
    And the dump of the $err hash ref:
    error => There was a problem with your picture. Probably too big. request => /account/update_profile_image.json
    The "probably too big" is not a very good error message, is it? :) I also tried it with a 5px x 5px file and it spat out the same error. As I said earlier, the connection to twitter is working, because I can successfully post using the update() method.
      Thanks for posting your code and the errors. I don't see anything obviously wrong with your code. These are the only suggestions I can think of:
      1. Try printing $raw to a local file and see if you can successfully view it with an image program.
      2. Google around to see if Twitter's API might be broken for that function.
      Good luck!

      It's all fine and dandy until someone has to look at the code.
        Thanks. I was just on #net-twitter on and spoke with the author. It seems that my code is solid, but the reason it is failing is that twitter is simply too busy. Apparently, when their servers get overloaded, image uploads from the web interface or the API tend to fail. I'm glad it wasn't just me! :)


Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://759088]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2023-03-22 20:18 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (60 votes). Check out past polls.