If the gmail import fails to call the $gmailer->disconnect, repeated attempts to retrieve a contact list will always retrieve the contact list that was created with the first users credentials.

If the first attempt was with a bad login, subsequent, possibly successful attempts will continue to use the bad login, making it appear that the gmail integration is not working.

Simple change: add $gmailer->disconnect() immediately after calling $gmailer->snapshot, like so:

function importGmail($login, $password) {
    include ('scripts/importGmail.class.php');
    global $names;
    global $emails;
    $gmailer = new GMailer();
    if($gmailer->created) {
      $gmailer->setLoginInfo($login, $password, $my_timezone, 0);
      //if you are using a proxy then uncomment the following single line and modify it according to your settings.
      //$gmailer->setProxy("proxy.company.com");
      if($gmailer->connect()) {
        $gmailer->fetchBox(GM_CONTACT, 'all', '');
        $snapshot = $gmailer->getSnapshot(GM_CONTACT);
        $gmailer->disconnect();
        if (!empty($snapshot->contacts)) {
        foreach($snapshot->contacts as $key => $value) {
          $names[] = $value['name'];
          $emails[]= $value['email'];
        }
      }
      }
    }
   return array($names, $emails);
  }

thanks for the work you have done in developing this module.

Comments

soosa’s picture

wonderful!, thanks for the hint :-)

hadsie’s picture

Status: Active » Closed (fixed)

Not sure if this was ever incorporated into the module, but I'm marking this issue as "closed". The D5 version of this module is no longer being maintained. The original version had scripts that no longer worked and some that weren't compatible with the GPL. The D6 version is being developed now and is a complete re-write using the OpenInviter library. If you wish to submit a backport to D5 I'll be happy to add that to CVS. Please see the project page for more details.