dongmo20030416 2016-12-12 11:00
浏览 33
已采纳

如何从Google Directory API检索电话号码?

I'm using Directory API with PHP to retrieve all users. A response for a user who has a phone number added looks like this:

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 ( ) )

The phone number was set 5 days ago (it's there), but as you can see the "phones" array is empty.

This is how I use the API:

$directory_service = new Google_Service_Directory($client);
$params = array('domain' => $domain);
$results = $directory_service->users->listUsers($params);
$users = $results->getUsers();

I can't figure out what's wrong. Do I need to enable any settings? How can I get users' phone numbers?

Thanks in advance.

  • 写回答

1条回答 默认 最新

  • duanlaican1849 2016-12-13 23:27
    关注

    You might have added phone numbers for the domain contact but in your own contacts data. These will display 'merged' with the domain contact details in the Contacts UI and appear correct to you. They won't be visible to others though or be stored in the domain data.

    Do this for testing:

    1. Pick a domain user account and add a phone number for them using the admin console Users UI. Admin console > Users > (select User) > Account > Contact information > Edit > Add a phone > Click Update User.
    2. To confirm your addition, use Try this API here: https://developers.google.com/admin-sdk/directory/v1/reference/users/get and just enter your user account name from 1 (email address) in userKey, for viewType select admin_view and click Execute.

    You should see the phone data in the JSON returned. Once you can do this you can retest your PHP code.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 优博讯DT50高通安卓11系统刷完机自动进去fastboot模式
  • ¥15 minist数字识别
  • ¥15 在安装gym库的pygame时遇到问题,不知道如何解决
  • ¥20 uniapp中的webview 使用的是本地的vue页面,在模拟器上显示无法打开
  • ¥15 网上下载的3DMAX模型,不显示贴图怎么办
  • ¥15 关于#stm32#的问题:寻找一块开发版,作为智能化割草机的控制模块和树莓派主板相连,要求:最低可控制 3 个电机(两个驱动电机,1 个割草电机),其次可以与树莓派主板相连电机照片如下:
  • ¥15 Mac(标签-IDE|关键词-File) idea
  • ¥15 潜在扩散模型的Unet特征提取
  • ¥15 iscsi服务无法访问,如何解决?
  • ¥15 感应式传感器制作的感应式讯响器