如何从 Google 目录 API 中检索 phone 号码?
How can I retrieve phone numbers from Google Directory API?
我正在使用目录 API 和 PHP 检索所有用户。
添加了 phone 个号码的用户的响应如下所示:
Google_Service_Directory_User Object ( [collection_key:protected] =>
nonEditableAliases [addresses] => [agreedToTerms] => 1 [aliases] =>
[changePasswordAtNextLogin] => [creationTime] =>
2016-11-29T14:21:30.000Z [customSchemas] => [customerId] => 1234
[deletionTime] => [emails] => Array ( [0] => Array ( [address] =>
test@companymail.com [primary] => 1 ) [1] => Array ( [address] =>
test@companymail.com ) ) [etag] => "tagg" [externalIds] =>
[hashFunction] => [id] => 12344 [ims] => [includeInGlobalAddressList]
=> 1 [ipWhitelisted] => [isAdmin] => [isDelegatedAdmin] => 1 [isMailboxSetup] => 1 [kind] => admin#directory#user [lastLoginTime]
=> 2016-12-12T10:13:31.000Z [nameType:protected] => Google_Service_Directory_UserName [nameDataType:protected] =>
[nonEditableAliases] => Array ( [0] =>
test@companymail.com.test-google-a.com [1] => test@companymail.com )
[notes] => [orgUnitPath] => / [organizations] => [password] =>
[phones] => [primaryEmail] => test@companymail.com [relations] => [suspended] => [suspensionReason] => [thumbnailPhotoEtag] =>
[thumbnailPhotoUrl] => [websites] =>
[internal_gapi_mappings:protected] => Array ( ) [modelData:protected]
=> Array ( [name] => Array ( [givenName] => TestNAme [familyName] => TestNAme [fullName] => TestNAme TestNAme ) ) [processed:protected] =>
Array ( ) )
phone 数字是在 5 天前设置的(它在那里),但是正如您所见,"phones" 数组是空的。
我就是这样使用 API:
$directory_service = new Google_Service_Directory($client);
$params = array('domain' => $domain);
$results = $directory_service->users->listUsers($params);
$users = $results->getUsers();
我不知道出了什么问题。我需要启用任何设置吗?
如何获取用户的 phone 号码?
提前致谢。
您可能已经为域联系人添加了 phone 个号码,但在您自己的联系人数据中。这些将在联系人 UI 中显示 'merged' 和域联系人详细信息,并且对您来说是正确的。它们不会被其他人看到,也不会存储在域数据中。
这样做是为了测试:
- 选择一个域用户帐户并使用管理控制台用户 UI 为他们添加一个 phone 号码。管理控制台 > 用户 >(select 用户)> 帐户 > 联系信息 > 编辑 > 添加 phone > 单击更新用户。
- 要确认您的添加,请在此处使用“尝试此操作”API:https://developers.google.com/admin-sdk/directory/v1/reference/users/get 并在 userKey 中输入您的用户帐户名(从 1(电子邮件地址)开始,viewType select
admin_view
并单击执行。
您应该会在返回的 JSON 中看到 phone 数据。完成此操作后,您可以重新测试 PHP 代码。
我正在使用目录 API 和 PHP 检索所有用户。 添加了 phone 个号码的用户的响应如下所示:
Google_Service_Directory_User Object ( [collection_key:protected] => nonEditableAliases [addresses] => [agreedToTerms] => 1 [aliases] => [changePasswordAtNextLogin] => [creationTime] => 2016-11-29T14:21:30.000Z [customSchemas] => [customerId] => 1234 [deletionTime] => [emails] => Array ( [0] => Array ( [address] => test@companymail.com [primary] => 1 ) [1] => Array ( [address] => test@companymail.com ) ) [etag] => "tagg" [externalIds] => [hashFunction] => [id] => 12344 [ims] => [includeInGlobalAddressList] => 1 [ipWhitelisted] => [isAdmin] => [isDelegatedAdmin] => 1 [isMailboxSetup] => 1 [kind] => admin#directory#user [lastLoginTime] => 2016-12-12T10:13:31.000Z [nameType:protected] => Google_Service_Directory_UserName [nameDataType:protected] => [nonEditableAliases] => Array ( [0] => test@companymail.com.test-google-a.com [1] => test@companymail.com ) [notes] => [orgUnitPath] => / [organizations] => [password] => [phones] => [primaryEmail] => test@companymail.com [relations] => [suspended] => [suspensionReason] => [thumbnailPhotoEtag] => [thumbnailPhotoUrl] => [websites] => [internal_gapi_mappings:protected] => Array ( ) [modelData:protected] => Array ( [name] => Array ( [givenName] => TestNAme [familyName] => TestNAme [fullName] => TestNAme TestNAme ) ) [processed:protected] => Array ( ) )
phone 数字是在 5 天前设置的(它在那里),但是正如您所见,"phones" 数组是空的。
我就是这样使用 API:
$directory_service = new Google_Service_Directory($client);
$params = array('domain' => $domain);
$results = $directory_service->users->listUsers($params);
$users = $results->getUsers();
我不知道出了什么问题。我需要启用任何设置吗? 如何获取用户的 phone 号码?
提前致谢。
您可能已经为域联系人添加了 phone 个号码,但在您自己的联系人数据中。这些将在联系人 UI 中显示 'merged' 和域联系人详细信息,并且对您来说是正确的。它们不会被其他人看到,也不会存储在域数据中。
这样做是为了测试:
- 选择一个域用户帐户并使用管理控制台用户 UI 为他们添加一个 phone 号码。管理控制台 > 用户 >(select 用户)> 帐户 > 联系信息 > 编辑 > 添加 phone > 单击更新用户。
- 要确认您的添加,请在此处使用“尝试此操作”API:https://developers.google.com/admin-sdk/directory/v1/reference/users/get 并在 userKey 中输入您的用户帐户名(从 1(电子邮件地址)开始,viewType select
admin_view
并单击执行。
您应该会在返回的 JSON 中看到 phone 数据。完成此操作后,您可以重新测试 PHP 代码。