Hello!
I already searched the web and the forum, but I didn't find anything reliable. Sorry if the question was already asked before.
My request is really simple: getting an ID of an image (path known).
Best way is to use the following line:
list ($ret, $id) = GalleryCoreApi::fetchItemIdByPath('/myalbum/mypicture.jpg');
Okey, but now.. I have no idea how to use the API. I'm trying a very simple request. This is my "test.php" in the gallery2 root folder:
Quote:
<?php
include 'modules/core/classes/GalleryCoreApi.class';
list ($ret, $id) = GalleryCoreApi::fetchItemIdByPath('/myalbum/mypicture.jpg');
print($id);
?>
Is this enough to use the API? Only including the GalleryCoreApi.class? Or do i have to put it into a function / class that inherits something?
The result of the "test.php" is following:
Quote:
Fatal error: Call to a member function getDebug() on a non-object in C:\Program Files\EasyPHP-5.3.6.1\www\PhotoGalleries\gallery2\modules\core\classes\helpers\GalleryPluginHelper_simple.class on line 212
I think I'm missing the point...
Thank you for helping me out!
Kakmael
Posts: 16504
I've never used the API directly, I'd start here:
http://codex.gallery2.org/Gallery2:API
And possibly also look at the G2 Import module that's in G3 as it uses the API.
____________________________________________
Like Gallery? Like the support? Donate now!
Posts: 12
mmhhh yes I already looked at that page. Unfortunately I didn't find any example... or maybe I'm blind
And the list of all methods are : http://gallery.menalto.com/apidoc/GalleryCore/Classes/GalleryCoreApi.html
But still no examples
Kakmael
Posts: 16504
Take a look at this:
https://github.com/gallery/gallery3/blob/master/modules/g2_import/helpers/g2_import.php
As well as embed.php that's included with G2
This:
http://codex.gallery2.org/Gallery2:How_to_visually_embed_G2_in_your_own_website_using_embedded_mode
And this:
http://www.flashyourweb.com/staticpages/index.php?page=gallery2_embed-o-rator
Granted those last 2 are intended for embedding Gallery 2 into your site but it might get you a lot closer to what you want too.
And this might help too:
http://codex.gallery2.org/Gallery2:GalleryEmbed:getImageBlock
____________________________________________
Like Gallery? Like the support? Donate now!
Posts: 1642
The error you got is because you only included a small part of the gallery framework. In your example, you'll need to include the GalleryPluginHelper_simple.class file and any others that come up as being needed to complete the request.
Including small parts of the framework as needed will work but the proper way is to use the embed facility to load the complete framework
The stuff above is for accessing the API from outside G2. If you are going to be accessing from within G2, such as in a module, you don't need to do anything as the full framework is loaded with every request and you just call the API functions in your module code.
--
dakanji.com
Posts: 12
Oh yes!
That was exactly my problem, I didn't include not enough of the framework. With initializing embed.php, it works perfectly!
Thanks a lot, nivekiam and Dayo
Kakmael
Posts: 1
Hi,
I want to add Google map on my site with Direction and distance between two areas. Please help me i want Code for this solution.