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.
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:
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.
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.
Related
Is it possible to get the email from an external teams call participant?
The data is retrieved from https://graph.microsoft.com/beta/subscriptions
I resolve our ids with the graph user enpoint https://graph.microsoft.com/v1.0/users/{id}
I am writing the callrecords into our ticketing system and would like to display the email from an participant from a different tenant.
[participants] => Array
(
[0] => Array
(
[acsUser] =>
[spoolUser] =>
[phone] =>
[guest] =>
[encrypted] =>
[onPremises] =>
[acsApplicationInstance] =>
[spoolApplicationInstance] =>
[applicationInstance] =>
[application] =>
[device] =>
[user] => Array
(
[id] => myId
[displayName] => Nico Bleiler
[tenantId] => myTenant
)
)
[1] => Array
(
[acsUser] =>
[spoolUser] =>
[phone] =>
[guest] =>
[encrypted] =>
[onPremises] =>
[acsApplicationInstance] =>
[spoolApplicationInstance] =>
[applicationInstance] =>
[application] =>
[device] =>
[user] => Array
(
[id] => externalId
[displayName] => External User
[tenantId] => hisTenant
)
)
)
As far as i know i can not query a user which is not in my tenantId.
But is there a way i could atleast retrieve his email?
You can use list participants to get the list of participants from a given call. Being said that i dont remember there is a way exists at this point to get email address of Microsoft teams user. Being said that i remember two closest uservoice items for uservoice1, uservoice2- go ahead, upvote them - so that Microsoft can consider implementing it.
I believe i used the userPrincipalName property to get out emails.
GET /users/{id | userPrincipalName} which can be found here:
https://learn.microsoft.com/en-us/graph/api/user-get?view=graph-rest-1.0&tabs=http
Here i am having one multidimensional array , using this array i want to take from emails array i want to take user email value like abc#gmail.com and from name array i want to take value givenName like Raju and from image array i want to take url like www.domain.com
print_r($user_info);
Array
(
[kind] => plus#person
[etag] => "EhMivDE25UysA1M2v-A/ZXQsxHAN9QSz-hQoXfQGzFyLWdQ"
[gender] => male
[emails] => Array
(
[0] => Array
(
[value] => abc#gmail.com
[type] => account
)
)
[objectType] => person
[id] => 100776010499118027035
[displayName] => Raju r
[name] => Array
(
[familyName] => r
[givenName] => Raju
)
[url] => https://plus.google.com/100776010499118027035
[image] => Array
(
[url] => www.domain.com
[isDefault] =>
)
[isPlusUser] => 1
[language] => en
[circledByCount] => 1
[verified] =>
[domain] => www.facebook.com
)
Expected Results
abc#gmail.com
Raju
www.domain.com
I tried like this
foreach($user_info['emails'] as $result){
$user_email = $result['value'];
foreach($result['name'] as $nameresult){
$user_name = $nameresult['givenName'];
}
}
Seems name does not seems to be an array of arrays like emails. So you can directly take that name instead of inner loop
foreach($user_info['emails'] as $result){
$user_email = $result['value'];
}
In this it the email value will be overridden each time and will hold only last email element value.
&
$user_info['name']['familyName'];
$user_info['image']['url'];
What I understand from the above set of data is that a user will have multiple email ids and a one and one image url. So above logic works.
Can someone help me with eTapestry API. I'm using applyDefinedValues Method . Documentation is here: https://www.blackbaudhq.com/files/etapestry/api/methods/applyDefinedValues.html
Everything works fine when updating fields that are defined as text, int or other values, but I don't know how to update multiselect type.
I tried to send data like this:
$dv1["value"] = array('Eclipses','Electional','Estoteric/Spritual/Occult');
but system updates as new value 'Array'?
eTapestry return values looks like this:
[18] => Array
(
[dataType] => 0
[displayType] => 2
[fieldName] => My Interests
[fieldRef] => 249.0.39428157
[value] => Electional
[valueRef] => 249.0.39782431
)
[19] => Array
(
[dataType] => 0
[displayType] => 2
[fieldName] => My Interests
[fieldRef] => 249.0.39428157
[value] => Estoteric/Spritual/Occult
[valueRef] => 249.0.39782420
)
........
[21] => Array
(
[dataType] => 0
[displayType] => 2
[fieldName] => My Interests
[fieldRef] => 249.0.39428157
[value] => Archetypal Cosmology
[valueRef] => 249.0.39782417
I have in the code the procedure that retrieve the list of all segment.
$SegmentArray = $service->management_segments->listManagementSegments();
I need to retrieve anly segment for the specific segment.
If I use this output :
echo "results:<br><pre>".print_r($SegmentArray,true)."</pre>";
The list (JSON) is:
Array
(
[kind] => analytics#segments
[username] => nomeaccount#gmail.com
[totalResults] => 13
[startIndex] => 1
[itemsPerPage] => 1000
[items] => Array
(
[0] => Array
(
[id] => -1
[kind] => analytics#segment
[selfLink] => https://www.googleapis.com/analytics/v3/management/segments/gaid::-1
[segmentId] => gaid::-1
[name] => All Visits
[definition] =>
)
...
How I can filter this data for profile?
Thank's!
I am trying to make a system that follow new user's Facebook friend automatically.
When a user log in to the website with their Facebook ID, the server store their Facebook id number into the db column.
Therefore, I would like to retrieve Facebook friend id numbers and match them to current signed user's Facebook ID numbers.
here is array data from Facebook friend.
Array (
[data] => Array (
[0] => Array (
[name] => James1
[id] => 1111
)
[1] => Array (
[name] => James2
[id] => 2222
)
[2] => Array (
[name] => James3
[id] => 3333
)
[3] => Array (
[name] => James4
[id] => 4444
)
[4] => Array (
[name] => James5
[id] => 5555
) [5] => Array (
[name] => James6
[id] => 6666
)
)
)
I tried to use in_array PHP command, but didn't work.
Can you give me an idea how to make this?
try:
foreach($yourArr['data'] as $val) {
if($yourUserId == $val["id"]) {
///found
break;
}
}