Internet Explorer Embedded

nomorefood

Joined: 2005-08-27
Posts: 6
Posted: Sat, 2005-10-15 20:11

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>");
  } 

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sat, 2005-10-15 20:29

not related to your problem but...

Quote:
$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>");
}

use GalleryEmbed::init, no need to call GalleryInitFirstPass directly.

Quote:
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>");
}

there's a missing if ($ret->isError()), you should check all return values!

Quote:
$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>");
}
}

you wanna do all that on each G2 request? that's highly inefficient and slow!

Quote:
$embedPath = 'gallery/embed.php';
...
$params = array('embedPath' => $embedPath,

that's wrong. 'embedPath' isn't the path to embed.php. see docs/EMBEDDING for a few examples.

Quote:
$params = array('embedPath' => $embedPath,
'relativeG2Path' => 'gallery/',
'activeUserId' => $g2_user->getId(),
'fullInit' => true);

embedUri is missing.

Quote:
$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>');
}

no login is required between ::init and ::handleRequest.

Quote:
$ret = GalleryEmbed::done();
if ($ret->isError()) {
printf("Error Initializing Gallery<br>");
}

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)