lildude / phpSmug

:camera: phpSmug is a simple object orientated wrapper for the new SmugMug API v2, written in PHP.
https://lildude.github.io/phpSmug
MIT License
42 stars 19 forks source link

Can't upload (from URI & from Local) #44

Closed antoine-nedelec closed 6 years ago

antoine-nedelec commented 6 years ago

Hello,

First I would like to thank you for your work, which is really helpful to use Smugmug :) !

I have successfully used those functions from the API: loggin/oauth, fetch any kind of element, post a folder, edit a folder, delete a folder, ...

Basically everything is working well, but I'm now trying to upload something, but nothing is working until now (I have a symfony4 environement, last PHP, last version of your library).

For the Local upload (as it is mentionned option is optionnal, I removed everything inside):

$options = []
$response = $client->upload('album/7Wwsdk', "/Users/antoinenedelec/Documents/Photos/IMG_0375.JPG", $options);

I then have this response:

object(stdClass)[1065] public 'stat' => string 'fail' (length=4) public 'method' => string 'smugmug.images.upload' (length=21) public 'code' => int 5 public 'message' => string 'system error' (length=12)

I did tried to chmod 777 my file, nothing will do.

For the external upload:

        $image_allow_insecure = true;
        $image_uri = 'http://lasoundbox.fr/img/app_bg.png';
        $image_cookie = '';
        $image_title = 'test';
        $image_caption = 'Caption';
        $image_hidden= false;
        $image_file_name = 'test.jpg';
        $image_keyword = '';

        $options = [
            'AllowInsecure' => $image_allow_insecure,
            'Uri' => $image_uri,
            'Cookie' => $image_cookie,
            'Title' => $image_title,
            'Caption' => $image_caption,
            'Hidden' => $image_hidden,
            'FileName' => $image_file_name,
            'Keywords' => $image_keyword,
        ];

        $response = $client->post('album/7Wwsdk!uploadfromuri', $options);

And i get this response:

{"Response":{"Uri":"/api/v2/album/7Wwsdk!uploadfromuri","UriDescription":"Upload a photo or video from elsewhere on the web","EndpointType":"UploadFromUri"},"Code":404,"Message":"Not Found"}

I did checked that my "7Wwsdk" element exists, and is indeed a folder.

I think i'm probably doing something wrong here, as everything else is working but couldn't fint what yet ? Maybe because i'm in local for the development (using Symfony built in local server) ?

Any idea ?

antoine-nedelec commented 6 years ago

Damn, one good night of sleep and I found by myself in 5 minutes.. I inputed the node id of the folder.., not the album key of the folder. Just needed some sleep, well no more problem then ;) !

lildude commented 6 years ago

😆 I was just about to ask if that's what you were doing. Good to see you got it after a little 💤