2012-07-26 47 views
0

我試着去檢索域中的所有用戶,但我得到一個錯誤..谷歌的cPanel和Zend/PHP

下載Zend庫

文檔:

https://developers.google.com/google-apps/provisioning/?hl=da#retrieving_user_accounts

獲取此錯誤:

Fatal error: Call to undefined method Zend_Gdata_HttpClient::retrieveAllUsers() 

腳本:

require_once 'Zend/Loader.php'; 
Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); 
Zend_Loader::loadClass('Zend_Gdata_Gapps'); 

$email = '[email protected]'; 
$password = 'password'; 
$client = Zend_Gdata_ClientLogin::getHttpClient($email, $password, Zend_Gdata_Gapps::AUTH_SERVICE_NAME); 

echo '<pre>'; 
print_r($client->retrieveAllUsers()); 
echo '</pre>'; 
+0

的cPanel標籤不被用於「谷歌的cPanel」,只是以供將來參考。 – tubaguy50035 2012-07-26 13:42:09

回答

1

好像您嘗試訪問了錯誤的對象的實例的方法retrieveAllUsers(Zend_Gdata_HttpClient而不是Zend_Gdata_Gapps)。

試試這個:

$client = Zend_Gdata_ClientLogin::getHttpClient($email, $password, Zend_Gdata_Gapps::AUTH_SERVICE_NAME); 
$gdata = new Zend_Gdata_Gapps($client, 'mydomain.com'); 
$users = $gdata->retrieveAllUsers(); 
+0

好的謝謝..但那不是文檔告訴我..現在我得到這個錯誤'您必須同意在使用此API的Google Apps服務條款'您在哪裏同意這些條款? – clarkk 2012-07-26 14:10:49

+0

使用您在上面的php代碼中使用的用戶憑據登錄谷歌應用程序。我認爲您一旦登錄就應該在這裏看到這些條款。 – Wouter 2012-07-26 14:24:43