• Gear
  • Shots
  • Photo Craft
  • Video
  • Wide Angle
  • Support
  • New Stuff
  • More
Support SmugMug APIs, Hacks & Tricks Problem with perl wrapper?

FAQtoid

Ever wanted to create an Avatar? Creating an Avatar!

Searching Dgrin with Google Searching with Google

Dgrin Challenges

Congratulations to the Winner of DSS #128 (Sunrise or Sunset), ShootingStar.

The next Dgrin Challenge DSS #129 (Silhouette Revisited ) is open for entries through May 27th, 2013 at 8:00pm PDT.

As always, we look forward to your participation but please do take a moment to read through the rules before posting your entry.

Past DSS Challenge Winners, DSS Challenge Rules, and other important DSS Challenge information is here.

Need some help with Accessories?

Tutorials

Ever find yourself wondering just how someone managed to create an image using different effects?

Here are three simple tutorials we hope will encourage you to try something new.

The Hot Seat

A lifelong interest in landscape photography has led Eyal Oren to make a study of his adopted hometown of Marblehead, MA. As you can see, his dedication is paying off!

Africa!

Dgrinners Harryb, Pathfinder, and others joined Andy Williams and Marc Muench on Safari in East Africa recently. Here are some awesome threads to check out!

 
Thread Tools Display Modes
Old Jul-08-2012, 01:24 PM
#1
arjunrc is offline arjunrc OP
The laziest photographer
arjunrc's Avatar
Problem with perl wrapper?
Hi, I am getting my feet wet with the perl wrapper for Smugmug.
It's logging in fine, but when I Try and print my albums its empty. I have one album called 'World' - why is it not showing up?

Code:
print "Logging into Smugmug";
my $sm_api = WWW::SmugMug::API->new(
        {
            sm_api_key => $mykey,
            secure     => 1,
        }
    );

$rv=$sm_api->login_withPassword(
        {
            EmailAddress => 'my@email.com',
            Password     => 'mypassword',
        }
    );
    
print "Login result is ", $rv->{'stat'},"\n";
my $albums = $sm_api->albums_get();
foreach my $album (@{$albums->{'Albums'}}) {
	$title=$album->{'title'};
	print $title;
}
The output is:
Logging into SmugmugLogin result is ok
__________________
inspire.roychowdhury.org
Old Jul-08-2012, 01:43 PM
#2
arjunrc is offline arjunrc OP
The laziest photographer
arjunrc's Avatar
Ok, I did some more investigation. The 'stat' result for login is ok, but for the album_get, it returns 'Invalid API key'. The Key is exactly what I got from smugmug - I got two strings, a key and a secret. I am using the key - I don't see a provision to enter the secret in the perl APIs.
How come login worked then?

Also, I found and older thread where someone posted you need to associate a cookie file to it. I know how to associate it to a user agent (LWP), but how do you connect it to $sm_api variable? Sorry, my knowledge of perl is very basic :-)
__________________
inspire.roychowdhury.org

Last edited by arjunrc; Jul-08-2012 at 02:25 PM.
Old Jul-08-2012, 03:08 PM
#3
arjunrc is offline arjunrc OP
The laziest photographer
arjunrc's Avatar
Ok, solved. I took at look at the code of WWW::Smugmug::API

To link it to a cookies file, you need to use the ua element of sm_api_key like so. This may help other folks using perl:

Code:
my $cj=HTTP::Cookies->new(
    file => "sm_cookies.dat",
    autosave => 1,
  );

print "Logging into Smugmug";
my $sm_api = WWW::SmugMug::API->new(
        {
            sm_api_key => $mykey,
            secure     => 1,
        }
    );

$sm_api->{ua}->cookie_jar($cj);
__________________
inspire.roychowdhury.org
Tell The World!  
Similar Threads Thread Starter Forum Replies Last Post
7d Frame Capture Problem Rob Pauza Cameras 12 Apr-19-2012 06:17 PM
Big Problem accessing My site with Internet Explorer LCPHOTO Bug Reporting 8 Nov-19-2011 10:52 PM
D80 problem Giphsub Cameras 14 Jan-17-2008 05:20 AM
Hit Counter Problem twincitiesphoto SmugMug Pro Sales Support 0 Dec-30-2007 06:40 PM
Weird problem with mapping docwalker SmugMug Support 13 May-30-2006 04:56 AM


Thread Tools
Display Modes

Posting Rules  
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump