Exemplo n.º 1
0
/**
 * Retrieves the list of users for the current domain and outputs
 * that list.
 *
 * @param  Zend_Gdata_Gapps $gapps The service object to use for communicating with the Google Apps server.
 * @param  boolean          $html  True if output should be formatted for display in a web browser.
 * @return void
 */
function retrieveAllUsers($gapps, $html)
{
    if ($html) {
        echo "<h2>Registered Users</h2>\n";
    }
    $feed = $gapps->retrieveAllUsers();
    if ($html) {
        echo "<ul>\n";
    }
    foreach ($feed as $user) {
        if ($html) {
            echo "  <li>";
        } else {
            echo "  * ";
        }
        echo $user->login->username . ' (';
        if ($html) {
            echo htmlspecialchars($user->name->givenName . ' ' . $user->name->familyName);
        } else {
            echo $user->name->givenName . ' ' . $user->name->familyName;
        }
        echo ')';
        if ($html) {
            echo '</li>';
        }
        echo "\n";
    }
    if ($html) {
        echo "</ul>\n";
    }
}
Exemplo n.º 2
0
<?php

require_once 'init.php';
$email = '*****@*****.**';
$password = '******';
$domain = "domain.com";
require_once 'secret.php';
//here are the actual email/pw/domain values >D
require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();
$client = Zend_Gdata_ClientLogin::getHttpClient($email, $password, Zend_Gdata_Gapps::AUTH_SERVICE_NAME);
$service = new Zend_Gdata_Gapps($client, $domain);
$feed = $service->retrieveAllUsers();
foreach ($feed as $user) {
    echo "  * " . $user->login->username . ' (' . $user->name->givenName . ' ' . $user->name->familyName . ")\n";
    var_dump($es->add('member', $user->login->username, json_encode(array('handle' => $user->login->username, 'name' => $user->name->givenName . ' ' . $user->name->familyName, 'level' => 1))));
}