URLs for albums

LockeLocke Registered Users Posts: 10 Big grins
edited February 11, 2010 in SmugMug Support
Hey Guys,

I'm really new at using the API so maybe I'm just missing something. What I want to do is have a PHP function on my blog that will get the URLs for my SmugMug galleries via the API so I can feed them into an unordered list as links. I was looking at albums.get and albums.getinfo but it seems they do not expose that information. Is there another way to go about this? or am I missing something obvious?

Thanks,
--Locke

Comments

  • SamirDSamirD Registered Users Posts: 3,474 Major grins
    edited February 8, 2010
    Are you using the phpsmug wrapper?
    Pictures and Videos of the Huntsville Car Scene: www.huntsvillecarscene.com
    Want faster uploading? Vote for FTP!
  • PBolchoverPBolchover Registered Users Posts: 909 Major grins
    edited February 9, 2010
    Could you possibly get them from an RSS feed? Or by querying the yoursite.smugmug.com/iphone page?
  • LockeLocke Registered Users Posts: 10 Big grins
    edited February 9, 2010
    SamirD,

    Yes, I am using the wrapper. This is what I have so far:

    $albums = $f->albums_get('NickName=name','Heavy=1');
    $images = $f->images_get("AlbumID={$albums}", "Heavy=1");
    echo '<ul>';
    foreach ($images as $pic) {
    echo '<li><a href="'.$pic.'">'.$albums.'</a></li>';
    }
    echo '</ul>';

    The above gets me 23 links (one for each pic in the album) that look similar to this:

    http://name.smugmug.com/Projects/album/10825351_hKBR9#768867522_sCffc

    http://name.smugmug.com/Projects/album/10825351_hKBR9#768867507_pNzL3

    That has been my solution so far since the images.get in the API contains the URL. The problem I'm faced with now is digging into the array prior to the loop that prints the links and stripping out the all the ID numbers for the image and then doing something like array_unique() so I only get one link per album.
  • SamirDSamirD Registered Users Posts: 3,474 Major grins
    edited February 10, 2010
    Hmmm...I'll have to look at the code you posted when I get a chance. In the meantime, check out this little app that does what you want (but not in real-time if that's what you're looking for): http://smugroom.com/tools/gallery-list/
    Pictures and Videos of the Huntsville Car Scene: www.huntsvillecarscene.com
    Want faster uploading? Vote for FTP!
  • LockeLocke Registered Users Posts: 10 Big grins
    edited February 10, 2010
    Thanks, I'll take a look at that.
  • SamirDSamirD Registered Users Posts: 3,474 Major grins
    edited February 10, 2010
    Locke wrote:
    SamirD,

    Yes, I am using the wrapper. This is what I have so far:

    $albums = $f->albums_get('NickName=name','Heavy=1');
    $images = $f->images_get("AlbumID={$albums}", "Heavy=1");
    echo '<ul>';
    foreach ($images as $pic) {
    echo '<li><a href="'.$pic.'">'.$albums.'</a></li>';
    }
    echo '</ul>';

    The above gets me 23 links (one for each pic in the album) that look similar to this:

    http://name.smugmug.com/Projects/album/10825351_hKBR9#768867522_sCffc

    http://name.smugmug.com/Projects/album/10825351_hKBR9#768867507_pNzL3

    That has been my solution so far since the images.get in the API contains the URL. The problem I'm faced with now is digging into the array prior to the loop that prints the links and stripping out the all the ID numbers for the image and then doing something like array_unique() so I only get one link per album.
    I think you've over coded it. There's a URL field available for the heavy response in 1.2.2 of the API. I haven't used it myself, but I think it would be perfect for what you are trying to do.

    See what this gets you (you may have to adjust syntax as I haven't tested this code). It should be a list of all the album urls and the titles next to them:

    $albums = $f->albums_get('NickName=name','Heavy=1');
    foreach ($albums as $album)
    {
    $eventAlbums[] = "URL: {$album} Title: {$album}\n";
    }
    print "$eventAlbums";
    Pictures and Videos of the Huntsville Car Scene: www.huntsvillecarscene.com
    Want faster uploading? Vote for FTP!
  • LockeLocke Registered Users Posts: 10 Big grins
    edited February 11, 2010
    Thanks,

    I will give that a shot. Thanks for looking into it. :D
  • SamirDSamirD Registered Users Posts: 3,474 Major grins
    edited February 11, 2010
    Locke wrote:
    Thanks,

    I will give that a shot. Thanks for looking into it. :D
    Let me know if it works. thumb.gif

    I'm not a programmer, but I can figure out code if I have to. For me, practicing once a while doesn't hurt.
    Pictures and Videos of the Huntsville Car Scene: www.huntsvillecarscene.com
    Want faster uploading? Vote for FTP!
Sign In or Register to comment.