Help needed: remote login using Gallery's embed API

regic

Joined: 2008-08-20
Posts: 2
Posted: Wed, 2008-08-20 13:46

Hi, guys,
I just wondered how am I supposed to login into Gallery using it's embed API. The problem is that regarding this:
http://gallery.menalto.com/apidoc/GalleryCore/Classes/GalleryEmbed.html#methodlogin
I need to pass a variable called $extUserId. I tried to pass id's (like 0,1,23,56), usernames (like 'admin', 'someuser', 'whatever'), random strings and number and I always got error. So do you have an idea what shout I pass as an $extUserId?
And how am I supposed to get/set the Active user because most of the methods require $activeUserId (probably I could get it after logging??).
Thanks in advance :)

P.S.: Sorry if I posted it in a wrong category...

 
regic

Joined: 2008-08-20
Posts: 2
Posted: Mon, 2008-08-25 08:18

Huh, I can't believe that nobody used the API for such functionality...

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Mon, 2008-08-25 10:28

You're asking in the wrong place ;) I'm moving this thread to the Integration/Embedding Development forum.

Have you read the documentation also?
http://codex.gallery2.org/Development
http://codex.gallery2.org/Gallery2:Embedding
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Mon, 2008-08-25 12:35
regic wrote:
I need to pass a variable called $extUserId. I tried to pass id's (like 0,1,23,56), usernames (like 'admin', 'someuser', 'whatever'), random strings and number and I always got error. So do you have an idea what shout I pass as an $extUserId?

From the documentation, it looks like $extUserId is the user id in the system into which Gallery is embedded (drupal, whatever) - see for instance the isExternalIdMapped function on the same page.

If you want to create an embedded session based on an internal Gallery username/userId you don't need to use the Embedded class. Just load the GalleryUser Entity using the id or username and send it to the (global) Gallery object's setActiveUser function:

global $gallery;
list ($ret, $myUser) = GalleryCoreApi::loadEntitiesById($myUserId, 'GalleryUser');
if ($ret) {
    //die appropriately with user not found error
    .
    .
    .
}
$gallery->setActiveUser($myUser);
//start session, Gallery::Login event here etc.
.
.
.

If you want to be picky you can start a session and send a 'Gallery::Login' event too - see GalleryEmbed::login(...) for code you can crib.

That would be my first approach to try, anyway.