Peter,
I tried manually passing the image/jpg, but that didnt seem to
help. Still returning a 403.
The following command works fine, so there must be something wrong
with the way I'm passing the mime type to curl in PHP:
curl -F '[email protected];type=image/png' -H
'Expect:' -u {username}:{password}
http://twitter.com/account/update_profile_image.xml
On Jan 20, 7:57 am, DeBetta <[email protected]> wrote:
> I had similar issues when first working with images. I ended up using
> "image/jpg" for the mimetype regardless of the actual type of file and
> that seemed to clear up the issue.
>
> --Peter
>
> On Jan 20, 8:46 am, Kevin Thompson <[email protected]> wrote:
>
> > Matt,
> > I tried changing my script to generate a gif, and my issues with
> > twitter dissapeared, but my image was no longer rendering properly so
> > I switched the output back to png and added the mimetype to the image
> > data, but now I'm not getting any response.
>
> > foreach($_POST as $key => $var){
> > $POST[$key] = htmlspecialchars($var,ENT_QUOTES);
> > }
>
> > if($POST['twittername'] != '' && $POST['twitterpass'] != ''){
>
> > $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);
> > $image_array = explode('.',$user->profile_image_url);
>
> > $filename = $POST['twittername'] . '-' . time() . '.png';
> > $badge = imagecreatefrompng($POST['badge']);
> > switch($image_array[(sizeof($image_array) - 1)]){
> > 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;
> > }
>
> > imagealphablending($badge,1);
> > imagealphablending($avatar,1);
> > imagecopy($avatar,$badge,0,0,0,0,48,48);
> > imagepng($avatar,$filename);
>
> > //*
> > $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, 4);
> > curl_setopt($curl, CURLOPT_POSTFIELDS,array('image' => "@
> > $filename;type=image/png"));
> > curl_setopt($curl, CURLOPT_USERPWD, $POST['twittername'] .
> > ':' .
> > $POST['twitterpass']);
> > $response = curl_exec($curl);
> > $info = curl_getinfo($curl);
> > curl_close($curl);
>
> > imagedestroy($badge);
> > imagedestroy($avatar);
> > unlink($filename);
> > // */
>
> > On Jan 19, 12:18 pm, Matt Sanford <[email protected]> wrote:
>
> > > Hi Kevin,
>
> > > I find that error message misleading. If the image could not be
> > > processed for any reason the error says "possibly too big". That's
> > > normally the case with user uploads but it seems like from the API
> > > it's more often something else. Looking back through the Google Group
> > > it seems like GIF is predominantly the issue. If you create a similar
> > > 1x1 PNG does it do the same thing? We support GIF and it should work,
> > > but knowing what works and what doesn't will help narrow it down.
>
> > > Thanks;
> > > — Matt Sanford / @mzsanford
>
> > > On Jan 19, 2009, at 10:01 AM, DeBetta wrote:
>
> > > > I just tested the update_profile_image API call and sent a 190K image
> > > > without issue.
>
> > > > What kind of image are you trying to post? Do you have sample code you
> > > > can share?
>
> > > > --Peter
>
> > > > On Jan 19, 11:16 am, Kevin Thompson <[email protected]> wrote:
> > > >> I'm attempting to write a simple script to update the user's profile
> > > >> image, but I am getting a response that the image is possible too big
> > > >> each time. The file that I'm attempting to set as the user avatar is
> > > >> no larger than 5k, and it fails.
>
> > > >> I created a 1px by 1px white gif which weighed in at about 43 bytes
> > > >> and it worked.
>
> > > >> My suspicion is that for some reason the API is not correctly
> > > >> calculating the file size of the image data, or it's checking for a
> > > >> much smaller value than 700k.- Hide quoted text -
>
> > - Show quoted text -