예제 #1
0
 function getAddressbook($gmail_acc, $gmail_pwd)
 {
     $my_timezone = 0;
     $gmailer = new GMailer();
     if ($gmailer->created) {
         $gmailer->setLoginInfo($gmail_acc, $gmail_pwd, $my_timezone);
         echo "Created gmailer obj...<br />";
         if ($gmailer->connect()) {
             echo 'connected with gmailer obj...<br />';
             // GMailer connected to Gmail successfully.
             // Do something with it.
             //Get the contacts
             // For "Inbox"
             $gmailer->fetchBox(GM_CONTACT, "all", "");
             $snapshot = $gmailer->getSnapshot(GM_CONTACT);
             //Outputs an array of the contacts
             return $snapshot;
             return $snapshot->contacts;
             //Outputs the number of contacts
             //var_dump($snapshot->contacts_total);
         } else {
             return $gmailer->lastActionStatus();
         }
     }
 }
예제 #2
0
$gm->getCookieFromBrowser();
$mode = $_GET['mode'];
if (strlen($mode) != 0 and $mode != 'enter' and !$gm->isConnected()) {
    header("Location: ?");
}
switch ($mode) {
    case 'new':
        $tpl = new Templates('tpls');
        $tpl->set('contact_form', array('name' => "", 'email' => "", 'id' => -1));
        $tpl->set('main', 'content', $tpl->parse('contact_form'));
        print $tpl->parse('main');
        break;
    case 'edit':
        $id = $_GET['id'];
        if (!$gm->fetchBox(GM_CONTACT, 'detail', $id)) {
            die($gm->lastActionStatus());
        }
        $sps = $gm->getSnapshot(GM_CONTACT);
        $tpl = new Templates('tpls');
        foreach ($sps->contacts as $c) {
            $tpl->set('contact_form', array('name' => $c['name'], 'email' => $c['email'], 'id' => $id));
            $tpl->set('main', 'content', $tpl->parse('contact_form'));
        }
        print $tpl->parse('main');
        break;
    case 'del':
        $id = $_GET['id'];
        if (!$gm->deleteContact($id)) {
            die($gm->lastActionStatus());
        }
        header("Location: ?mode=list");