Hey All. Anyone have any idea why the code below wouldn't work in Internet Explorer but would work fine in FireFox to log a user in. I've tried clearing cookies and cache to no success.
$embedPath = 'gallery/embed.php';
require($embedPath);
$ret = GalleryInitFirstPass();
if ($ret->isError()) {
printf("Problem with initial pass<br>");
}
list ($ret, $core) = GalleryCoreApi::loadPlugin('module', 'core', true);
if ($ret->isError()) {
printf("Error Loading API<br>");
}
list ($ret, $g2_user) = GalleryCoreApi::fetchUserByUsername($values['username']);
if ($ret->isError()) {
printf("Error Locating User<br>");
}
if (!isset($g2_user)) {
printf("Gallery User Invalid<br>");
}
$ret = GalleryEmbed::isExternalIdMapped($g2_user->getId(), 'GalleryUser');
if ($ret->isError()) {
$ret = GalleryEmbed::addExternalIdMapEntry($g2_user->getId(), $g2_user->getId(), 'GalleryUser');
if ($ret->isError()) {
printf("Error creating map entry<br>");
}
}
$params = array('embedPath' => $embedPath,
'relativeG2Path' => 'gallery/',
'activeUserId' => $g2_user->getId(),
'fullInit' => true);
$ret = GalleryEmbed::init($params);
if ($ret->isError()) {
printf("Error Initializing Gallery<br>");
}
$ret = GalleryEmbed::login($g2_user->getId());
if ($ret->isError()) {
printf('Gallery Login Not Done<br>');
}
GalleryEmbed::handleRequest();
$ret = GalleryEmbed::done();
if ($ret->isError()) {
printf("Error Initializing Gallery<br>");
}
Posts: 32509
not related to your problem but...
use GalleryEmbed::init, no need to call GalleryInitFirstPass directly.
there's a missing if ($ret->isError()), you should check all return values!
you wanna do all that on each G2 request? that's highly inefficient and slow!
that's wrong. 'embedPath' isn't the path to embed.php. see docs/EMBEDDING for a few examples.
embedUri is missing.
no login is required between ::init and ::handleRequest.
no ::done is required after handleRequest.
all in all, you're using the G2 functions correctly, but very inefficiently.
- take a look at the sample g2 wrapper attached to the 1st post of the sticky Embedding and Integration topic.
- take a look at docs/EMBEDDING
- for an efficient handling of users, see existing integrations (WPG2, joomla)