I am trying to write a piece of code in PHP that would allow administrators to add users to my application. I found some "Getting started" pages along with some authorization and authentication tutorials at https://developers.google.com/api-client-library/php/start/get_started Also, I found a very simple example at https://github.com/google/google-api-php-client#basic-example. A pretty good one can be found here: https://stackoverflow.com/a/26532344. But still, I need to do stuff like create user, delete user etc. But I can't seem to be able to find any good reference or documentation on the methods of directory API. For example, based on the last mentioned example, I know that I should use "dir->users->insert()" method to create a user (which I found only by searching through the suggestions in my IDE, but I don't know what parameters to pass to the method and what they mean). I know there is this API reference on inserting users, but again, it doesn't say anything specifically how to write it in PHP. So, is there any complete and thorough reference and documentation that describes all the methods of the Google Directory API for PHP?
Asked
Active
Viewed 831 times
-1
-
What is wrong with my question (as I got a -1 vote)? – Patrik Chynoranský Aug 10 '15 at 16:59
2 Answers
1
This question is 6 years old, but still what comes up with you search this question in Google. (And the answers still aren't helpful)
Regardless, this is a super basic example of creating a new user using the PHP Directory API:
// Get your client somehow (there's lot of example code for that part)
$service = new Google_Service_Directory($client);
// Build the UserName Object
$user_name = new Google_Service_Directory_UserName();
$user_name->givenName = 'TestUSer1First';
$user_name->familyName = 'TestUSer1Last';
// Build the User Object
$user = new Google_Service_Directory_User();
$user->password = "testuser1";
$user->hashfunction = "SHA-1";
$user->primaryEmail = "testuser1@domain.com";
$user->password = "testuser1password";
$user->setName($user_name);
$results = $service->users->insert($user);
Unfortunately, Google doesn't document any of their Client API Wrappers, but their code is relatively self explanatory if you view it on github.
For example:

Tim Cortesi
- 11
- 1
0
Sounds like you're looking for the API reference and the API reference for the user insert method

Vex
- 1,489
- 13
- 20
-
Well, not really. Those references are very generally described and don't say anything about which method to use in PHP. But thank you for your answer. – Patrik Chynoranský Apr 26 '15 at 13:26
-
Well those API docs will tell you what the parameters are, and what they mean, so that should get you started. – Vex Apr 26 '15 at 13:31
-
That's true, but it did not help me to be able to implement it in PHP. – Patrik Chynoranský Apr 26 '15 at 13:47