我一直在嘗試將成員添加到我的Google應用組中。我正在嘗試下面的代碼,但它會引發錯誤。不知道什麼是做錯了。Google Groups Directory API - 將用戶添加到組引發錯誤 - PHP
include_once 'api-client/autoload.php';
$clientId = 'xxxxxxxxxxxxxxxxx.apps.googleusercontent.com';
$serviceAccountName = '[email protected]';
$delegatedAdmin = '[email protected]';
$keyFile = 'mw-gxxxxxxxx.p12';
$appName = 'Example App';
$scopes = array(
'https://www.googleapis.com/auth/admin.directory.group'
);
$creds = new Google_Auth_AssertionCredentials(
$serviceAccountName,
$scopes,
file_get_contents($keyFile)
);
$creds->sub = $delegatedAdmin;
$client = new Google_Client();
$client->setApplicationName($appName);
$client->setClientId($clientId);
$client->setAssertionCredentials($creds);
$dir = new Google_Service_Directory($client);
$member = new Google_Service_Directory_Member(array('[email protected]',
'kind' => 'admin#directory#member',
'role' => 'MEMBER',
'type' => 'USER'));
$list = $dir->members->insert('01tuee7433xxxxx', $member);
錯誤:
Fatal error: Uncaught exception 'Google_Service_Exception' with message
'Error calling POST https://www.googleapis.com/admin/directory/v1/groups/01tuee7433v8xwz/members: (400) Missing required field: memberKey'
'缺少必填字段:memberKey' – Himal 2014-11-21 09:11:55
在哪裏以及如何擺放? – MECHANICWEB 2014-11-21 09:31:49
我使用相同的代碼。但它給了我這個錯誤 - 調用未定義的方法Google_Client :: setAssertionCredentials() – Aashi 2016-05-10 05:19:21