我有一个小脚本可以强制我们 Google Apps 域中的用户在下次登录时更改密码。我使用的是 Zend Framework 1.11.13,但我在 1.12.0 上也得到了相同的结果。
在 google 文档 ( https://developers.google.com/google-apps/provisioning/#updating_a_user_account )中更新用户的示例似乎已过时或不正确,因为在客户端对象上调用 updateUser 总是返回未定义的方法错误。
这是我的代码:
<?php
set_include_path(implode(PATH_SEPARATOR, array(
"/var/www/workspace/extlib/zend-framework/library/",
get_include_path(),
)));
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Gapps');
$client = Zend_Gdata_ClientLogin::getHttpClient("removed", "removed", Zend_Gdata_Gapps::AUTH_SERVICE_NAME);
$gdata = new Zend_Gdata_Gapps($client, 'domain.com');
$userEntry = $gdata->retrieveUser("a.username");
$userEntry->getLogin()->setChangePasswordAtNextLogin(true);
$gdata->updateUser("a.username", $userEntry);
我得到的错误是:
PHP Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Expected response code 200, got 500
Internal Error' in /var/www/workspace/extlib/zend-framework/library/Zend/Gdata/App.php:718
Stack trace:
#0 /var/www/workspace/extlib/zend-framework/library/Zend/Gdata.php(219): Zend_Gdata_App->performHttpRequest('PUT', 'https://apps-ap...', Array, '<atom:entry xml...', 'application/ato...', NULL)
#1 /var/www/workspace/extlib/zend-framework/library/Zend/Gdata/App.php(934): Zend_Gdata->performHttpRequest('PUT', 'https://apps-ap...', Array, '<atom:entry xml...', 'application/ato...')
#2 /var/www/workspace/extlib/zend-framework/library/Zend/Gdata/Gapps.php(272): Zend_Gdata_App->put(Object(Zend_Gdata_Gapps_UserEntry), 'https://apps-ap...', NULL, NULL, Array)
#3 /var/www/workspace/extlib/zend-framework/library/Zend/Gdata/App.php(1025): Zend_Gdata_Gapps->put(Object(Zend_Gdata_Gapps_UserEntry), 'https://apps-ap...', NULL, NULL, Array)
#4 /var/www/workspace/extlib/zend-framework/library/Zend/Gdata/Gapps.php(1005): Zend_ in /var/www/workspace/extlib/zend-framework/library/Zend/Gdata/App.php on line 718
我在这里和那里添加了一些调试代码,并且用户肯定可以正常加载,因此它似乎不是权限错误或网络错误,因为初始请求工作正常。当我尝试调用 updateUser 时出现错误。
任何帮助将非常感激!