You may want to check that $post isn't set to "false". This happens if
file_get_contents() cannot read the file. If that's not the case then
I would try using fopen() instead of file_get_contents().

Cheers,
-Jeff

On Dec 10, 5:46 pm, girafenok <[email protected]> wrote:
> Hello!
>
> I'm trying to upload photo with Picasaweb API using two different
> method (PHP), but  i am getting error 400 "Not an image".
>
> First method:
>                 //Get authorization------------------------
>                 $auth=.....
>                //-----------------------------
>                 $post = file_get_contents('/home/girafenok/1.jpg');
>                 $postsize=strlen($post);
>                 $albumid="....";
>                 $userid="....";
>                 $headers = "POST /data/feed/api/user/$userid/albumid/$albumid 
> HTTP/
> 1.1\r\n"
>                                 ."Host: picasaweb.google.com\r\n"
>                                 ."Content-Length: ".$postsize."\r\n"
>                                 ."Content-Type: image/jpeg\r\n"
>                                 ."Authorization: GoogleLogin 
> auth=".$auth."\r\n\r\n"
>                                 .$post;
>
>                $fp = fsockopen("picasaweb.google.com",80);
>                fwrite($fp,$headers);
>                while(!feof($fp)){echo fread($fp,4096);}
>                fclose($fp);
>
> Second method:
>          //Get authorization------------------------
>                 $auth=.....
>         //-----------------------------
>         $xml = file_get_contents('/home/girafenok/1.jpg');
>         $header  =  array("Content-Type: image/jpeg", "Content-Length:
> ".strlen($xml), "Slug: test.jpg", "Authorization: GoogleLogin auth=".
> $auth,"MIME-Version: 1.0");
>         $albumid="....";
>         $userid="....";
>         $ch = curl_init();
>         curl_setopt($ch, CURLOPT_URL,"http://picasaweb.google.com/data/
> feed/api/user/ $userid/albumid/$albumid");
>         curl_setopt($ch, CURLOPT_POST, 1);
>         curl_setopt($ch, CURLOPT_POSTFIELDS, $xml."\n");
>         curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
>         curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
>         $http_result = curl_exec($ch);
>         curl_close ($ch);
>         echo $http_result;
>
> Also, i am trying to read file with fopen/fread and 'rb' mode, but
> i'am getting the same error "Not an image".
>
> What i'm doing wrong?
>
> P.S. Sorry for my english
>
> Regards, girafenok.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Picasa Web Albums API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Picasa-Data-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to