Uploading Photos - albumID

b2ramub2ramu Registered Users Posts: 2 Beginner grinner

I'm using apiv2 and my process is as follows:

-Create a new Album
-Upload (x) photos into newly created Album
-Repeat process as needed

I can accomplish the above via the api but I'm having difficulty getting the AlbumID without having to make an extra call to the API, which seems unnecessary. Basically the uploader, per the documentation, requires the AlbumID as a parameter, however, when I create an Album via the API the JSON response returned doesn't include the AlbumID only the nodeID which means I have to make another call to the API.

My question is, Can I upload a photo via the api uploader using the nodeID and if so how? Otherwise, if I can't is there an easier way to get the AlbumID vs. doing a search for Albums and then having to parse the results?



  • gibertigiberti Registered Users Posts: 19 Big grins
    edited June 20, 2016
    Hi @b2ramu,

    In API v1.x, SmugMug expected an AlbumID, this is no longer current. In API v2 SmugMug expects an AlbumUri to specify the Album to upload to. The most up to date upload documentation on upload.smugmug.com is here: https://api.smugmug.com/api/v2/doc/reference/upload.html.

    To use your example:

    1. Create an album by POSTing to /api/v2/node/nod.gifeId!children (where nod.gifeId is the parent Node that the Album should be created under). Included in the Uris section of the response from that endpoint is the AlbumUri that was created.

    2a. You can upload to the new Album by passing a X-Smug-AlbumUri header with the value of the AlbumUri returned during the creation of the album. Pay special attention to what `X-Smug-Version` header you pass - v2!

    2b. An alternative to using upload.smugmug.com: It's also possible to upload an image to a specific album by posting directly to that Album. For example, if the newly created AlbumUri is /api/v2/album/abc123xyz, POSTing the image binary directly to the /api/v2/album/abc123xyz!images endpoint will upload the image to that Album. If you use the Live API browser, you can see what fields SmugMug expects for that endpoint.
    APIv2 and OAuth are your friend! Having issues? Just ask, I can help!
  • b2ramub2ramu Registered Users Posts: 2 Beginner grinner
    edited June 28, 2016
    Thank you @giberti. I was able to get it working using your suggestion, specifically 2a.
  • RonnieMarlerRonnieMarler Registered Users Posts: 3 Big grins
    2b appears to be what I want to do. but I am a noob. is there a php script I can put in an html block when I create a custom page that can get me started? I want my guests to be able to upload photos with Title and Captions.
  • gibertigiberti Registered Users Posts: 19 Big grins

    Hi @RonnieMarler

    Unfortunately it's not quite as simple as just some PHP code you can drop on a page. There are a few PHP libraries available from third party vendors that might help you with uploading to a specific gallery, however, the upload would need to first go to your server and then your server could use the SDK to send it to us.

    I'm not sure exactly what you are trying to accomplish, but have you looked into Guest Uploading? That may be easier to implement if you are willing to let people upload directly to your SmugMug account.

    APIv2 and OAuth are your friend! Having issues? Just ask, I can help!
Sign In or Register to comment.