Retreiving users last logged time and quota used?

37 views
Skip to first unread message

Juan Carlos Lopez

unread,
Jun 17, 2011, 2:24:33 PM6/17/11
to google-app...@googlegroups.com
Hello Im trying to retreive my user's last login time (and if it has been logged some time) and the user's actuall quota used. Using the API I get quota limit but not the actual used space for that user. And had not found the parameter to see when it was last logged in. This Info for the users is available when I access my domain admin pannel, but I need to get this info FROM the API.
 
So Is possible?? Im using this PHP code (how ever if you can point me to any resource I can translate it to what I need)
<?php
require_once "Zend/Loader.php";
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Gapps');

$domain = "MYDOMAIN";
$email = "MYADMINEMAIL;
$password = "MYADMINPASS";

$client = Zend_Gdata_ClientLogin::getHttpClient($email, $password, Zend_Gdata_Gapps::AUTH_SERVICE_NAME);
$service = new Zend_Gdata_Gapps($client, $domain);

$user = $service->retrieveUser('SOMEUSER');

echo 'Username: ' . $user->login->userName . "<br />\n";
echo 'Given Name: ' . $user->name->givenName . "<br />\n";
echo 'Family Name: ' . $user->name->familyName . "<br />\n";
echo 'Suspended: ' . ($user->login->suspended ? 'Yes' : 'No') . "<br />\n";
echo 'Admin: ' . ($user->login->admin ? 'Yes' : 'No') . "<br />\n";
echo 'Must Change Password: ' .
     ($user->login->changePasswordAtNextLogin ? 'Yes' : 'No') . "<br />\n";
echo 'Has Agreed To Terms: ' .
     ($user->login->agreedToTerms ? 'Yes' : 'No') . "<br />\n";
echo 'Quota: ' . $user->quota . "MB<br />\n";
?>
 
I Get this response:
 
Username: SOMEUSER
Password:
Given Name: Some User Full Name
Family Name: Mail
Suspended: No
Admin: No
Must Change Password: No
Has Agreed To Terms: Yes
Quota: 7168
 
Regards

Alexandre Jacquet

unread,
Jun 17, 2011, 2:28:08 PM6/17/11
to google-app...@googlegroups.com
Hello Juan,

I think this information you can retrieve using Report API, instead of Provisioning API



                                                                                           

Alexandre Jacquet

Google Apps Deployment Specialst 
São Paulo | SP | Brasil
Tel.: 55 11 8064 6882






--
You received this message because you are subscribed to the Google Groups "Google Apps Domain Information and Management APIs" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-apps-mgmt-apis/-/s_9MByzt-lEJ.
To post to this group, send email to google-app...@googlegroups.com.
To unsubscribe from this group, send email to google-apps-mgmt...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-apps-mgmt-apis?hl=en.

Juan Carlos Lopez

unread,
Jun 18, 2011, 2:14:55 PM6/18/11
to Google Apps Domain Information and Management APIs
I find this API references extremly confusing... I dont understand it
very well and looking for examples is VERY HARD all them uses diferent
ways to retreive info, and more confusing ways to distract me, worst
is that just copy and paste them, and run, do not work at all.

how ever... I find this example to "access" the reporting API but as
usuall with the Google API examples, it does not work! any help? lead
to a GOOD and WORKING tutorial to access the Reporting API in PHP ?,
Here's the code that not work (and is taken EXACTLY from the google
documentation pages, with just some changes to get my domain and the
today date)

<?php
$location = "https://www.google.com/hosted/services/v1.0/reports/
ReportingData";

$xml_response = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<rest xmlns=\"google:accounts:rest:protocol\"
xmlns:xsi=\" http://www.w3.org/2001/XMLSchema-instance \">
<type>Report</type>
<domain>MYDOMAIN</domain>
<date>".date('Y-m-d')."</date>
<page>1</page>
<reportType>daily</reportType>
<reportName>accounts</reportName>
</rest>\n";


// Communicate with google checkout
$ch = curl_init ($location);
curl_setopt ($ch, CURLOPT_POST, true); // Use a standard HTTP Post
curl_setopt ($ch, CURLOPT_POSTFIELDS, $xml_response);
curl_setopt ($ch, CURLOPT_HEADER, false);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); // Return transfer
of the string instead of outputting it directly.
curl_setopt ($ch, CURLOPT_TIMEOUT, 60); // The maximum number of
seconds to allow cURL functions to execute.

curl_setopt ($ch, CURLOPT_SSLVERSION, 3); // Latest SSL version
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0); // Don't checkname in
SSL cerfificate
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false); // No files holder
certificates to verify

$response = curl_exec ($ch);


if(curl_errno($ch)) {
trigger_error(curl_error($ch), E_USER_ERROR);
}
curl_close ($ch);

echo $response;
?>


And I get this RESPONSE from the google API

<?xml version="1.0" encoding="UTF-8" ?>
<hs:rest xmlns:hs="google:accounts:rest:protocol">
<hs:status>Failure(2001)</hs:status>
<hs:reason>AuthenticationFailure(1006)</hs:reason>
<hs:extendedMessage>No extended message available for this
error.</hs:extendedMessage>
<hs:result />
<hs:type />
</hs:rest>


Is not a way just to SEND THE login credentials? I find some OAUTH2
references to get "Authentiticated" but they get MORE AND MORE
confusing and has refernece to acess other services like Calendars or
other things like that and I had no clue, how to apply them in the
Reporting API

Claudio Cherubino

unread,
Jun 19, 2011, 3:28:18 PM6/19/11
to google-app...@googlegroups.com
Hi Juan Carlos,

To authenticate properly with the Reporting API you can either use OAuth (http://code.google.com/googleapps/domain/reporting/google_apps_reporting_api.html#Authentication) or the deprecated but still valid ClientLogin.
In the latter case please follow the instructions at http://code.google.com/googleapps/domain/gdata_provisioning_api_v2.0_developers_protocol.html#client_login but remember that instead of the Auth token you'll need to use the SID token.

I understand your issues in finding good complete examples for the Reporting API, we are in process of updating them and at the same time we recently deprecated ClientLogin and added support for OAuth to this API so please bear with us.
Thanks 

Claudio

--
You received this message because you are subscribed to the Google Groups "Google Apps Domain Information and Management APIs" group.
Reply all
Reply to author
Forward
0 new messages