Gallery API - Pulling images into your website

starkec

Joined: 2009-01-20
Posts: 4
Posted: Tue, 2009-01-20 05:40

I'm extremely new the gallery environment, and working on a project for a client who uses Gallery for managing their images. For our newest website project, I want to be able to pull a specific album from their Gallery into the new website. I've been trying to find imformation on the Gallery API, and thought it might be worth posting on here for details. I'm going to be setting up a flash photo gallery that pulls in an xml file (which contains the images). I will eventually want to be able to use the Gallery API to pull the ablum information (via PHP) and eventually have it post into an xml file. If anyone has had some experience doing this, I'd appreciate the help.

Thanks!

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Tue, 2009-01-20 10:18

Have a look at the simpleviewersource module which does pretty much exactly what you're asking. (Some familiarity with the SimpleViewer flash application from Airtight Interactive will be appropriate.)

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Tue, 2009-01-20 15:52
 
starkec

Joined: 2009-01-20
Posts: 4
Posted: Sun, 2009-01-25 23:15

Alecmyers,
I was able to install the simpleviewersource plugin and get everything activated on the gallery side. Yet when I post the necessary XMLpath it doesn't seem to do anything:

fo.addVariable("xmlDataPath", "http://pictures.thet.net/main.php?g2_view=simpleviewersource.XMLOut%26g2_itemId=4314");

Do you know if there's another area in Gallery where I have to enable the simpleviewer other than the plugin itself?

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Sun, 2009-01-25 23:44

SimpleViewer the Flash application isn't enabled or disabled from within Gallery.

simpleviewersource the Gallery Module is enabled/disabled (as are all Gallery modules) from the plugin page. For everything else

simpleviewersource codex page wrote:
All parameters are set in the Simpleviewer Tab of the Edit Album page.

Have you correctly set the "Enable (or disable) simpleviewer from displaying the pictures in this album and its sub-albums." setting for the albums you want to display (or their parents)?

 
starkec

Joined: 2009-01-20
Posts: 4
Posted: Mon, 2009-01-26 00:43

I have that parameter set to 'yes', so that it's enabled. I'm assuming that's what i want.

Here's a screenshot of my gallery interface
http://beta.thetfordacademy.org/images/screenshot.jpg

This is a test URL of the page using it:
http://beta.thetfordacademy.org/athletics/boys/basketball/

This is what the actual code looks like on the page:
<div id="flashcontent">
<p>AutoViewer requires JavaScript and the Flash Player. <a href="http://www.macromedia.com/go/getflashplayer/">Get Flash here.</a>
</div>
<script type="text/javascript">
var fo = new SWFObject("viewer.swf", "simpleviewer", "500", "660", "8", "#FFFFFF");
//Optional Configuration
fo.addVariable("xmlDataPath", "http://pictures.thet.net/main.php?g2_view=simpleviewersource.XMLOut%26g2_itemId=4314");
fo.addParam("quality", "best");
fo.write("flashcontent");
</script>
</div>

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Mon, 2009-01-26 00:57

IT looks like simpleviewersource is working fine, because if you plug this url into a browser and view the source generated
http://pictures.thet.net/main.php?g2_view=simpleviewersource.XMLOut&g2_itemId=4314 (note replace %26 with & when manually loading the url)
you get this:

<simpleviewerGallery thumbnailRows='1'
thumbnailColumns='6'
navPosition='bottom'
stagePadding='0'
frameWidth='1'
frameColor='0xC3C7D2'
textColor='0xC3C7D2'
maxImageWidth='500'
maxImageHeight='500'
thumbPath='http://pictures.thet.net/main.php?g2_view=simpleviewersource.DownloadThumb&amp;g2_itemId='
imagePath='http://pictures.thet.net/main.php?g2_view=simpleviewersource.DownloadMax&amp;g2_maxImageHeight=&amp;g2_maxImageWidth=&amp;g2_itemId='
> 
<image><filename>4315</filename><caption>IMG_5631</caption></image> 
<image><filename>4319</filename><caption>IMG_5632</caption></image> 
<image><filename>4322</filename><caption>IMG_5633</caption></image> 
<image><filename>4325</filename><caption>IMG_5634</caption></image> 
<image><filename>4328</filename><caption>IMG_5638</caption></image> 
</simpleviewerGallery>

Which is pretty healthy.

It looks like you're trying to load the xml from a domain other than the one hosting the SimpleViewer swf file, so you'll probably have to comply with Adobe's cross-domain xml policy mechanisms. See for instance http://sudhahariharan.wordpress.com/2007/09/04/what-is-this-cross-domainxml-file-anyway/

Could that be the problem?

 
starkec

Joined: 2009-01-20
Posts: 4
Posted: Mon, 2009-01-26 03:24

Alecmyers, are you a genius. I didn't even realize Adobe had this security in place.

So to get around it I created a php file that takes in the xml content from the Gallery URL, and then just pushes it back to the Simplerviewer. This way Simpleviewer is pulling a local php file, so the cross domain is no longer an issue.

I would have never figured that out without your help, thanks a bunch!

Just in case anyone else sees this, if you run into the same issue, just point your simpleviewer to a php file containing this code:

Quote:
<?php

$data=file_get_contents("http://www.domain.com/main.php?g2_view=simpleviewersource.XMLOut&g2_itemId=4314");

// now return the XML for SimpleViewer
header("Content-Type: text/xml");
print $data;
exit;
?>

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Mon, 2009-01-26 12:17

The best solution (doesn't require extra php) is to put a correctly-configured crossdomain.xml file in the webroot of the site hosting the Gallery installation, the site you want to load the data from.

http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_14213