phpSmug problems

james4coffeejames4coffee Registered Users Posts: 2 Beginner grinner
Hi,
I have a small script (from a mag) to use the api to display albums and images on a webpage. It was used for flickr so I've had to change it to fit with smugmug api etc. The problem I have is it doesn't work.
I've attached to script. If anyone could let me know if I've got something wrong I would be most grateful. I am new to all this and its a steep learning curve.

require_once("phpSmug.php");
$f = new phpSmug("my key from smugmug", "my app name" );

$f->login_anonymously();

$albums = $f->albums_get('my id');

$currset = $_GET;
if(!is_numeric($currset)) {
$currset = $albums[0];
}

$albuminfo = $f->albums_getInfo($currset);
$albumimages = $f->imagesInfo($currset);

I've removed to start and end php tags
Thanx in advance

Comments

  • lildudelildude Registered Users Posts: 70 Big grins
    edited June 3, 2008
    Hi,
    I have a small script (from a mag) to use the api to display albums and images on a webpage. It was used for flickr so I've had to change it to fit with smugmug api etc. The problem I have is it doesn't work.
    I've attached to script. If anyone could let me know if I've got something wrong I would be most grateful. I am new to all this and its a steep learning curve.

    require_once("phpSmug.php");
    $f = new phpSmug("my key from smugmug", "my app name" );

    $f->login_anonymously();

    $albums = $f->albums_get('my id');

    $currset = $_GET;
    if(!is_numeric($currset)) {
    $currset = $albums[0];
    }

    $albuminfo = $f->albums_getInfo($currset);
    $albumimages = $f->imagesInfo($currset);

    I've removed to start and end php tags
    Thanx in advance

    Hi James

    Glad to hear you're using phpSmug, but you've not stated which version you're using, nor what errors you are getting. You also appear to be attempting to use a method that doesn't exist (imagesInfo()).

    That aside, your problem is likely to be linked to the change in the SmugMug API which requires BOTH the album|photo ID and album|photo Key be passed to a few of the method calls See here for more details.

    What's more, you've also made a mistake in setting $currset to the album ID.

    The following changes should give you the desired outcome:
    <?php
    
    require_once("phpSmug.php");
    $f = new phpSmug("REMOVED", "Gallery Lightbox" );
    
    $d = $f->login_anonymously();
    
    $albums = $f->albums_get('James4coffee');
    
    $currset = $_GET['id'];
    $currkey = $_GET['Key'];
    if(!is_numeric($currset) || !is_numeric($currkey)) {
    	$currset = $albums[0]['id'];
    	$currkey = $albums[0]['Key'];
    }
    
    $albuminfo = $f->albums_getInfo($currset, $currkey);
    $albumimages = $f->images_get($currset, $currkey);
    ?>
    

    NOTE: I've removed your API key from the above.

    Oh, and you may find the debug() method useful in your debugging.

    If for example, you wanted to see what $albumimages holds, just add the following line after it's been assigned:
    $f->debug($albumimages);
    

    The debug() method takes strings, objects and arrays and prints them in a plain text that is easy to read and understand.

    HTH
    Colin
  • james4coffeejames4coffee Registered Users Posts: 2 Beginner grinner
    edited June 5, 2008
    Hi Colin,

    Thanks for help. I've tried your changes, and see where I was going wrong, but it still doesn't work. I've been trying v 1.0.10 and v 1.1.7 (not together) to no avail. I've tried the debug-ing and get no output either. All I get is a blank page. I think it is getting stuck on the php as I have some html after which isn't being used. I'm beginning to wonder if PHP is working on my server. :-(

    If you have any other suggestions, I'm all ears.

    In the meantime I'll keep trying....

    James
  • lildudelildude Registered Users Posts: 70 Big grins
    edited June 5, 2008
    Hi Colin,

    Thanks for help. I've tried your changes, and see where I was going wrong, but it still doesn't work. I've been trying v 1.0.10 and v 1.1.7 (not together) to no avail. I've tried the debug-ing and get no output either. All I get is a blank page. I think it is getting stuck on the php as I have some html after which isn't being used. I'm beginning to wonder if PHP is working on my server. :-(

    If you have any other suggestions, I'm all ears.

    In the meantime I'll keep trying....

    James

    If you copy and paste the code as I entered it above, it should work.

    If it doesn't, it's possibly something with your PHP. Ensure your PHP is working correctly - creating a file with <?php echo phpinfo(); ?> and viewing it should show you all your PHP config etc and should confirm your PHP is working.

    HTH
Sign In or Register to comment.