Options

API methods for "collect photos" feature

dounddound Registered Users Posts: 72 Big grins
edited November 15, 2011 in SmugMug API Support & Integrations
There doesn't seem to be any support in the 1.2.2 API for collecting photos.

Would it be possible to incorporate collecting photos into the API? This would be very useful for me anyway :).

Thanks!
«1

Comments

  • Options
    devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited May 5, 2010
    Hi David,

    Yes, we should have methods for collecting photos soon...it's been delayed by a few other projects.

    Cheers,

    David
    David Parry
    SmugMug API Developer
    My Photos
  • Options
    dounddound Registered Users Posts: 72 Big grins
    edited May 5, 2010
    Wonderful news! I'll keep an eye on the API update thread in the meantime :).

    Thanks!
  • Options
    dounddound Registered Users Posts: 72 Big grins
    edited July 19, 2010
    devbobo wrote: »
    Yes, we should have methods for collecting photos soon...it's been delayed by a few other projects.

    Hi David,

    Any guess about when API methods for collecting photos will be available? These would certainly be quite useful.

    Thanks,
    ~ David
  • Options
    devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited July 22, 2010
    G'day Dave,

    Sorry for the delay. I added smugmug.images.collect today so it should be going out with this week's push.

    I haven't added a method for uncollecting yet, as I'm in two minds about how to implement it. I initially was going to add smugmug.images.uncollect, but now I am leaning towards adding an optional AlbumID parameter to smugmug.images.delete which is result in uncollecting instead of deleting if the ImageID is 'Collected' within the supplied AlbumID.

    Cheers,

    David
    David Parry
    SmugMug API Developer
    My Photos
  • Options
    dounddound Registered Users Posts: 72 Big grins
    edited July 22, 2010
    devbobo wrote: »
    I added smugmug.images.collect today so it should be going out with this week's push.

    Thanks so much - you are awesome! clap.gif I'm really excited to have this functionality - I promise to put it to use soon after it is available.
    devbobo wrote: »
    G'day Dave,
    I haven't added a method for uncollecting yet, as I'm in two minds about how to implement it. I initially was going to add smugmug.images.uncollect, but now I am leaning towards adding an optional AlbumID parameter to smugmug.images.delete which is result in uncollecting instead of deleting if the ImageID is 'Collected' within the supplied AlbumID.

    Interesting. They're both good options. The latter is nice because it lets you delete an image from an album without requiring that you first determine if the image is collected or not. But whatever approach you choose will work just fine for me.

    Thanks David!
  • Options
    devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited July 22, 2010
    it's live
    David Parry
    SmugMug API Developer
    My Photos
  • Options
    dounddound Registered Users Posts: 72 Big grins
    edited July 30, 2010
    Thanks David, it works great! Now I'll look forward to the uncollect half of the API :).
  • Options
    SamirDSamirD Registered Users Posts: 3,474 Major grins
    edited November 12, 2010
    So how does one collect photos via the API? I'm guessing you specify the AlbumID where you want the image to go and then the Image ID and Key, but is that it?
    Pictures and Videos of the Huntsville Car Scene: www.huntsvillecarscene.com
    Want faster uploading? Vote for FTP!
  • Options
    devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited November 14, 2010
    SamirD wrote: »
    So how does one collect photos via the API? I'm guessing you specify the AlbumID where you want the image to go and then the Image ID and Key, but is that it?

    http://wiki.smugmug.net/display/API/show+1.2.2?method=smugmug.images.collect
    David Parry
    SmugMug API Developer
    My Photos
  • Options
    SamirDSamirD Registered Users Posts: 3,474 Major grins
    edited November 15, 2010
    I saw it in the wiki, but it never really explained what the albumID was for. Is it the album you want the image to go into?
    Pictures and Videos of the Huntsville Car Scene: www.huntsvillecarscene.com
    Want faster uploading? Vote for FTP!
  • Options
    devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited November 15, 2010
    SamirD wrote: »
    I saw it in the wiki, but it never really explained what the albumID was for. Is it the album you want the image to go into?

    yes, you obviously need to collect an image into an album.
    David Parry
    SmugMug API Developer
    My Photos
  • Options
    SamirDSamirD Registered Users Posts: 3,474 Major grins
    edited November 15, 2010
    Okay, makes sense. I'm not a programmer so the obvious things may not click with me immediately. thumb.gif

    btw, love the vomiting rainbow avatars you always have--they always make me laugh, lol.
    Pictures and Videos of the Huntsville Car Scene: www.huntsvillecarscene.com
    Want faster uploading? Vote for FTP!
  • Options
    SamirDSamirD Registered Users Posts: 3,474 Major grins
    edited November 15, 2010
    I just noticed you don't need the Album key on the destination album. Is this by design?
    Pictures and Videos of the Huntsville Car Scene: www.huntsvillecarscene.com
    Want faster uploading? Vote for FTP!
  • Options
    dounddound Registered Users Posts: 72 Big grins
    edited December 5, 2010
    devbobo wrote: »
    Sorry for the delay. I added smugmug.images.collect today so it should be going out with this week's push.

    I haven't added a method for uncollecting yet

    Dave, could you please add the uncollect method? Either of the approaches you had in mind works for me.

    Thanks!
  • Options
    David PLDavid PL Registered Users Posts: 80 Big grins
    edited September 11, 2011
    dound wrote: »
    Dave, could you please add the uncollect method? Either of the approaches you had in mind works for me.

    Thanks!


    This would be great. I'm looking for the same thing. Either of the two approaches for uncollecting would work for me as well, but having it built-in to the smugmug.images.delete API method might save one API call.
  • Options
    SamirDSamirD Registered Users Posts: 3,474 Major grins
    edited October 12, 2011
    SamirD wrote: »
    I just noticed you don't need the Album key on the destination album. Is this by design?
    I need an answer to this. I'm paying a developer to write some code and don't want to pay him twice. If there are plans to require the Key at some point, I'd like to know so I can make them write that into the their code.

    Also, the developer has been able to add an image to a album without a login for that user. You guys might want to look into this.
    Pictures and Videos of the Huntsville Car Scene: www.huntsvillecarscene.com
    Want faster uploading? Vote for FTP!
  • Options
    MSkaffariMSkaffari Registered Users Posts: 147 Major grins
    edited October 13, 2011
    SamirD wrote: »
    I need an answer to this. I'm paying a developer to write some code and don't want to pay him twice. If there are plans to require the Key at some point, I'd like to know so I can make them write that into the their code.

    Also, the developer has been able to add an image to a album without a login for that user. You guys might want to look into this.


    This method doesn't require AlbumKey as it's only available for the target gallery owner.

    I just tried collecting images to a gallery that is not owned by the same user I used to log in. The call succeeds (returns OK) but the image doesn't appear in the target gallery since I'm not the owner.
  • Options
    SamirDSamirD Registered Users Posts: 3,474 Major grins
    edited October 14, 2011
    MSkaffari wrote: »
    This method doesn't require AlbumKey as it's only available for the target gallery owner.

    I just tried collecting images to a gallery that is not owned by the same user I used to log in. The call succeeds (returns OK) but the image doesn't appear in the target gallery since I'm not the owner.
    Thank you for the reply. That makes sense.

    I'll have the developer look at his code. He doesn't have my login info or oauth, and yet was able to add an image into one of my galleries using the API. ne_nau.gif
    Pictures and Videos of the Huntsville Car Scene: www.huntsvillecarscene.com
    Want faster uploading? Vote for FTP!
  • Options
    MSkaffariMSkaffari Registered Users Posts: 147 Major grins
    edited October 14, 2011
    SamirD wrote: »
    Thank you for the reply. That makes sense.

    I'll have the developer look at his code. He doesn't have my login info or oauth, and yet was able to add an image into one of my galleries using the API. ne_nau.gif

    Let me take another look. Just to be sure.
  • Options
    devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited October 15, 2011
    SamirD wrote: »
    I need an answer to this. I'm paying a developer to write some code and don't want to pay him twice. If there are plans to require the Key at some point, I'd like to know so I can make them write that into the their code.

    Also, the developer has been able to add an image to a album without a login for that user. You guys might want to look into this.

    Hi Samir,

    Can you please provide details of which image he was able to add to which album ?

    Thanks,

    David
    David Parry
    SmugMug API Developer
    My Photos
  • Options
    SamirDSamirD Registered Users Posts: 3,474 Major grins
    edited October 18, 2011
    devbobo wrote: »
    Hi Samir,

    Can you please provide details of which image he was able to add to which album ?

    Thanks,

    David
    I have no idea anymore. The image was deleted and we moved on with development. :cry
    Pictures and Videos of the Huntsville Car Scene: www.huntsvillecarscene.com
    Want faster uploading? Vote for FTP!
  • Options
    SamirDSamirD Registered Users Posts: 3,474 Major grins
    edited October 19, 2011
    I need a complete example on how this is supposed to work. The only thing the developer I hired is able to do is collect photos into someone else's album, which he should notice able to do. He cannot collect from someone else's album into his own account, which is what we want to do. Please advise.
    Pictures and Videos of the Huntsville Car Scene: www.huntsvillecarscene.com
    Want faster uploading? Vote for FTP!
  • Options
    SamirDSamirD Registered Users Posts: 3,474 Major grins
    edited October 19, 2011
    we are using 1.2.2.
    Pictures and Videos of the Huntsville Car Scene: www.huntsvillecarscene.com
    Want faster uploading? Vote for FTP!
  • Options
    devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited October 19, 2011
    SamirD wrote: »
    we are using 1.2.2.

    this issue should be fixed live.

    Cheers,

    David
    David Parry
    SmugMug API Developer
    My Photos
  • Options
    SamirDSamirD Registered Users Posts: 3,474 Major grins
    edited October 19, 2011
    devbobo wrote: »
    this issue should be fixed live.

    Cheers,

    David
    What exactly was fixed? The ability to collect to galleries that weren't yours or the lack of a way to collect to your gallery or both? headscratch.gif
    Pictures and Videos of the Huntsville Car Scene: www.huntsvillecarscene.com
    Want faster uploading? Vote for FTP!
  • Options
    SamirDSamirD Registered Users Posts: 3,474 Major grins
    edited October 20, 2011
    SamirD wrote: »
    What exactly was fixed? The ability to collect to galleries that weren't yours or the lack of a way to collect to your gallery or both? headscratch.gif
    ne_nau.gif
    Pictures and Videos of the Huntsville Car Scene: www.huntsvillecarscene.com
    Want faster uploading? Vote for FTP!
  • Options
    SSSDevSSSDev Registered Users Posts: 4 Beginner grinner
    edited October 20, 2011
    I did get it to work with the destination's session. But the problem with having the Source login info still persists.
  • Options
    SSSDevSSSDev Registered Users Posts: 4 Beginner grinner
    edited October 20, 2011
    Hi MSkaffari,

    I am the developer conducting a collect on from a source to a destination.

    Here is an example of how I am doing this:
    //Using phpSmug to create the Session using API version 1.2.2
    // f1 is the source 
    $f1 = new phpSmug( "APIKey=<APIKEY>");
    if(strlen($s_pass) > 0)
    {
      $f1->login("EmailAddress=".$s_email."", "Password=".$s_pass."");
    }
    else
    {
      $f1->login_anonymously();
    }
    // f2 is the destination
    $f2 = new phpSmug( "APIKey=<APIKEY>");
    if(strlen($d_pass) > 0)
    {
      $f2->login("EmailAddress=".$d_email."", "Password=".$d_pass."");
    }
    else
    {
      $f2->login_anonymously();
    }
    
    // Ignoring some internal code and going straight to the collect
    // get the source images
    $images = $f1->images_get(...);
    // collect from source to destination
    $f1->images_collect("AlbumID={$dAlbum['id']}", "ImageID={$image['id']}", "ImageKey={$image['Key']}");
    
    So if you noticed, I am using $f1, or the Source's Session to conduct the collect. Two problems occur to this:
    1. The Destination Session is anonymous yet a collect can still occur so I can place images inside anyone's public Albums...
    2. Switching $f1 to $f2 during a collect will return Code 4: Invalid User EVEN when I use the destination username/email and password...

    That is the issue. It would seem to make more sense if the Destination's Session be used, not the source's.

    Thanks.
  • Options
    MSkaffariMSkaffari Registered Users Posts: 147 Major grins
    edited October 21, 2011
    SSSDev wrote: »
    Hi MSkaffari,

    I am the developer conducting a collect on from a source to a destination.

    Here is an example of how I am doing this:
    //Using phpSmug to create the Session using API version 1.2.2
    // f1 is the source 
    $f1 = new phpSmug( "APIKey=<APIKEY>");
    if(strlen($s_pass) > 0)
    {
      $f1->login("EmailAddress=".$s_email."", "Password=".$s_pass."");
    }
    else
    {
      $f1->login_anonymously();
    }
    // f2 is the destination
    $f2 = new phpSmug( "APIKey=<APIKEY>");
    if(strlen($d_pass) > 0)
    {
      $f2->login("EmailAddress=".$d_email."", "Password=".$d_pass."");
    }
    else
    {
      $f2->login_anonymously();
    }
    
    // Ignoring some internal code and going straight to the collect
    // get the source images
    $images = $f1->images_get(...);
    // collect from source to destination
    $f1->images_collect("AlbumID={$dAlbum['id']}", "ImageID={$image['id']}", "ImageKey={$image['Key']}");
    
    So if you noticed, I am using $f1, or the Source's Session to conduct the collect. Two problems occur to this:
    1. The Destination Session is anonymous yet a collect can still occur so I can place images inside anyone's public Albums...
    2. Switching $f1 to $f2 during a collect will return Code 4: Invalid User EVEN when I use the destination username/email and password...

    That is the issue. It would seem to make more sense if the Destination's Session be used, not the source's.

    Thanks.

    Thanks for the detailed explanation. Certainly based in the explanation this is not working as expected. Did you try this after 19th, when Devbobo said he fixed the issue?

    I tried this right after the fix and receive "Error 4; invalid user" when I don't have a valid session to the destination account.

    I can however collect images to my own albums from other users as long as they have enabled collecting images.

    I'll re-do my test today to be sure.
  • Options
    SSSDevSSSDev Registered Users Posts: 4 Beginner grinner
    edited October 27, 2011
    I have ran into some other issues using the SmugMug API 1.2.2. This problem is consistent to a majority of issues so if it were fixed, or explained, that would help a whole lot :)

    On an image delete:
    $f->images_delete("ImageID={$image['id']}");
    

    and on Image Collect/Copy:
    $f->images_collect("AlbumID={$destid}", "ImageID={$image['id']}", "ImageKey={$image['Key']}");
    $f->images_uploadFromURL("AlbumID={$destid}", "URL={$image['OriginalURL']}");
    

    There is a problem if the image is a copy itself, it will not remove the image or copy/collect the image since it originated from another source. Is that correct behavior?

    Edit: It may be on images that have been collected.

    Thanks!
Sign In or Register to comment.