I'm having the same problem as James with the pastebin script. "There
was a problem with your picture. Probably too big."

Additionally, I came across this thread having a similar error with
the api returning a 500 server error when attempting to update a user
profile image. My code is using PHP GD to essentially merge a
watermark with the users existing avatar, then send the raw image data
as an update.

$url = 'http://twitter.com/users/show/' . urlencode($POST
['twittername']) . '.xml';
                $curl = curl_init($url);

        curl_setopt($curl, CURLOPT_VERBOSE, 1);
        curl_setopt($curl, CURLOPT_NOBODY, 0);
        curl_setopt($curl, CURLOPT_HEADER, 0);
        curl_setopt($curl, CURLOPT_FOLLOWLOCATION,1);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

        $response = curl_exec($curl);
        curl_close($curl);
                $user = new SimpleXMLElement($response);

                $badge = imagecreatefrompng($POST['badge']);

                $image_array = explode('.',$user->profile_image_url);

                switch($image_array[4]){
                        case 'jpg':
                                $avatar = 
imagecreatefromjpeg($user->profile_image_url);
                                break;
                        case 'png':
                                $avatar = 
imagecreatefrompng($user->profile_image_url);
                                break;
                        case 'gif':
                                $avatar = 
imagecreatefromgif($user->profile_image_url);
                                break;
                        default:
                                $avatar = 
imagecreatefrompng($user->profile_image_url);
                                break;
                }

                imagecopymerge($avatar,$badge,0,0,0,0,48,48,100);

                ob_start();
                imagepng($avatar);
            $image = ob_get_contents();
            ob_end_clean();

                //*
                $url = 'http://twitter.com/account/update_profile_image.xml';

                $curl = curl_init();
                curl_setopt($curl, CURLOPT_URL, "$url");
                curl_setopt($curl, CURLOPT_POST, 1);
                curl_setopt($curl, CURLOPT_HTTPHEADER, array('Expect:'));
                curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 2);
                curl_setopt($curl, CURLOPT_POSTFIELDS,array('image' => urlencode
($image)));
                curl_setopt($curl, CURLOPT_USERPWD, $POST['twittername'] . ':' .
$POST['twitterpass']);
                $response = curl_exec($curl);
                curl_close($curl);

                echo $response;

                imagedestroy($badge);
                imagedestroy($avatar);


On Jan 6, 1:05 pm, "James N. Weber" <[email protected]> wrote:
> Chad- Thanks for all your help with this! I downloaded it from
> pastebin, and then uploaded it to my server, no changes. It is giving
> me the "There was a problem with your picture. Probably too big."
> error still, with several photos. Any ideas what's going on?
>
> On Jan 6, 1:31 pm, "Chad Etzel" <[email protected]> wrote:
>
> > So after some fiddling with your code, I got it to work:
>
> > I think part of the problem was that you can't use URLs to the image
> > (like you were doing).
>
> > Anyway, the following code (see pastebin link) gives examples of how
> > to do it with File Uploading through a form, or just using canned
> > local images from your server.
>
> >http://pastebin.com/f6eb4650c
>
> > Hope this helps,
> > -Chad
>
> > On Tue, Jan 6, 2009 at 3:15 PM, Stuart <[email protected]> wrote:
>
> > > 2009/1/6 James N. Weber <[email protected]>:
>
> > >> Thanks for the help, Chad. I think I need the PHP equivalent of -F in
> > >> curl- I'm not sure how to set that.
>
> > >> I tried changing it to CURLOPT_POSTFIELDS, and Twitter gave me a
> > >> "Something is technically wrong." page- the robot lobster with a
> > >> broken claw.
> > >> Any ideas?
>
> > > The code I took the below line from is not uploading an image to
> > > Twitter, but rather between two internal servers on one of the sites I
> > > maintain and it works fine for me...
>
> > > curl_setopt($ch, CURLOPT_URL, $url);
> > > curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect: '));
> > > curl_setopt($ch, CURLOPT_POST, 1);
> > > curl_setopt($ch, CURLOPT_POSTFIELDS, array('img' => '@'.$filename));
> > > curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
> > > $result = curl_exec($ch);
>
> > > Hope it helps you.
>
> > > -Stuart
>
> > > --
> > >http://stut.net/
>
>

Reply via email to