From 06f945f27840b53e57795dadbc38e76f7e11ab1c Mon Sep 17 00:00:00 2001 From: Horus3 Date: Mon, 24 Feb 2014 16:42:14 +0100 Subject: init --- .../manual/core/en/zend.gdata.gapps.html | 1287 ++++++++++++++++++++ 1 file changed, 1287 insertions(+) create mode 100644 zend/documentation/manual/core/en/zend.gdata.gapps.html (limited to 'zend/documentation/manual/core/en/zend.gdata.gapps.html') diff --git a/zend/documentation/manual/core/en/zend.gdata.gapps.html b/zend/documentation/manual/core/en/zend.gdata.gapps.html new file mode 100644 index 0000000..4e8598b --- /dev/null +++ b/zend/documentation/manual/core/en/zend.gdata.gapps.html @@ -0,0 +1,1287 @@ + + + + + Using Google Apps Provisioning - Zend Framework Manual + + + + + + + + +
+ + + + + + + + +
+ Using Google Spreadsheets + + + + +
+
+

Using Google Apps Provisioning

+ + +

+ Google Apps is a service which allows domain administrators to offer + their users managed access to Google services such as Mail, Calendar, + and Docs & Spreadsheets. The Provisioning API offers a programmatic + interface to configure this service. Specifically, this API allows + administrators the ability to create, retrieve, update, and delete + user accounts, nicknames, groups, and email lists. +

+ +

+ This library implements version 2.0 of the Provisioning API. Access to + your account via the Provisioning API must be manually enabled for + each domain using the Google Apps control panel. Only certain + account types are able to enable this feature. +

+ +

+ For more information on the Google Apps Provisioning API, including + instructions for enabling API access, refer to the » Provisioning + API V2.0 Reference. +

+ +

Note: Authentication
+ + + + The Provisioning API does not support authentication via AuthSub + and anonymous access is not permitted. All HTTP connections must + be authenticated using ClientAuth authentication. +
+

+ +

Setting the current domain

+ + +

+ In order to use the Provisioning API, the domain being + administered needs to be specified in all request URIs. In order + to ease development, this information is stored within both the + Gapps service and query classes to use when constructing + requests. +

+ +

Setting the domain for the service class

+ + +

+ To set the domain for requests made by the service class, + either call setDomain() or specify the domain + when instantiating the service class. For example: +

+ +
  1. $domain = "example.com";
  2. +
  3. $gdata = new Zend_Gdata_Gapps($client, $domain);
+ +
+ +

Setting the domain for query classes

+ + +

+ Setting the domain for requests made by query classes is + similar to setting it for the service class-either call + setDomain() or specify the domain when creating + the query. For example: +

+ +
  1. $domain = "example.com";
  2. +
  3. $query = new Zend_Gdata_Gapps_UserQuery($domain, $arg);
+ + +

+ When using a service class factory method to create a query, + the service class will automatically set the query's domain to + match its own domain. As a result, it is not necessary to + specify the domain as part of the constructor arguments. +

+ +
  1. $domain = "example.com";
  2. +
  3. $gdata = new Zend_Gdata_Gapps($client, $domain);
  4. +
  5. $query = $gdata->newUserQuery($arg);
+ +
+
+ +

Interacting with users

+ + +

+ Each user account on a Google Apps hosted domain is represented as + an instance of Zend_Gdata_Gapps_UserEntry. This class provides + access to all account properties including name, username, + password, access rights, and current quota. +

+ +

Creating a user account

+ + +

+ User accounts can be created by calling the + createUser() convenience method: +

+ +
  1. $gdata->createUser('foo', 'Random', 'User', '••••••••');
+ + +

+ Users can also be created by instantiating UserEntry, + providing a username, given name, family name, and password, + then calling insertUser() on a service object to + upload the entry to the server. +

+ +
  1. $user = $gdata->newUserEntry();
  2. +
  3. $user->login = $gdata->newLogin();
  4. +
  5. $user->login->username = 'foo';
  6. +
  7. $user->login->password = '••••••••';
  8. +
  9. $user->name = $gdata->newName();
  10. +
  11. $user->name->givenName = 'Random';
  12. +
  13. $user->name->familyName = 'User';
  14. +
  15. $user = $gdata->insertUser($user);
+ + +

+ The user's password should normally be provided as cleartext. + Optionally, the password can be provided as an SHA-1 digest if + login->passwordHashFunction is set to + 'SHA-1'. +

+
+ +

Retrieving a user account

+ + +

+ Individual user accounts can be retrieved by calling the + retrieveUser() convenience method. If the user is + not found, NULL will be returned. +

+ +
  1. $user = $gdata->retrieveUser('foo');
  2. +
  3.  
  4. +
  5. echo 'Username: ' . $user->login->userName . "\n";
  6. +
  7. echo 'Given Name: ' . $user->name->givenName . "\n";
  8. +
  9. echo 'Family Name: ' . $user->name->familyName . "\n";
  10. +
  11. echo 'Suspended: ' . ($user->login->suspended ? 'Yes' : 'No') . "\n";
  12. +
  13. echo 'Admin: ' . ($user->login->admin ? 'Yes' : 'No') . "\n"
  14. +
  15. echo 'Must Change Password: ' .
  16. +
  17.      ($user->login->changePasswordAtNextLogin ? 'Yes' : 'No') . "\n";
  18. +
  19. echo 'Has Agreed To Terms: ' .
  20. +
  21.      ($user->login->agreedToTerms ? 'Yes' : 'No') . "\n";
+ + +

+ Users can also be retrieved by creating an + instance of Zend_Gdata_Gapps_UserQuery, setting its username + property to equal the username of the user that is to be + retrieved, and calling getUserEntry() on a + service object with that query. +

+ +
  1. $query = $gdata->newUserQuery('foo');
  2. +
  3. $user = $gdata->getUserEntry($query);
  4. +
  5.  
  6. +
  7. echo 'Username: ' . $user->login->userName . "\n";
  8. +
  9. echo 'Given Name: ' . $user->login->givenName . "\n";
  10. +
  11. echo 'Family Name: ' . $user->login->familyName . "\n";
  12. +
  13. echo 'Suspended: ' . ($user->login->suspended ? 'Yes' : 'No') . "\n";
  14. +
  15. echo 'Admin: ' . ($user->login->admin ? 'Yes' : 'No') . "\n"
  16. +
  17. echo 'Must Change Password: ' .
  18. +
  19.      ($user->login->changePasswordAtNextLogin ? 'Yes' : 'No') . "\n";
  20. +
  21. echo 'Has Agreed To Terms: ' .
  22. +
  23.      ($user->login->agreedToTerms ? 'Yes' : 'No') . "\n";
+ + +

+ If the specified user cannot be located a ServiceException + will be thrown with an error code of + Zend_Gdata_Gapps_Error::ENTITY_DOES_NOT_EXIST. + ServiceExceptions will be covered in the exceptions chapter. +

+
+ +

Retrieving all users in a domain

+ + +

+ To retrieve all users in a domain, call the + retrieveAllUsers() convenience method. +

+ +
  1. $feed = $gdata->retrieveAllUsers();
  2. +
  3.  
  4. +
  5. foreach ($feed as $user) {
  6. +
  7.     echo "  * " . $user->login->username . ' (' . $user->name->givenName .
  8. +
  9.         ' ' . $user->name->familyName . ")\n";
  10. +
  11. }
+ + +

+ This will create a Zend_Gdata_Gapps_UserFeed object which + holds each user on the domain. +

+ +

+ Alternatively, call getUserFeed() with no + options. Keep in mind that on larger + domains this feed may be paged by the server. For more + information on paging, see the paging chapter. +

+ +
  1. $feed = $gdata->getUserFeed();
  2. +
  3.  
  4. +
  5. foreach ($feed as $user) {
  6. +
  7.     echo "  * " . $user->login->username . ' (' . $user->name->givenName .
  8. +
  9.         ' ' . $user->name->familyName . ")\n";
  10. +
  11. }
+ +
+ +

Updating a user account

+ + +

+ The easiest way to update a user account is to retrieve the + user as described in the previous sections, make any desired + changes, then call save() on that user. Any + changes made will be propagated to the server. +

+ +
  1. $user = $gdata->retrieveUser('foo');
  2. +
  3. $user->name->givenName = 'Foo';
  4. +
  5. $user->name->familyName = 'Bar';
  6. +
  7. $user = $user->save();
+ + +

Resetting a user's password

+ + +

+ A user's password can be reset to a new value by updating + the login->password property. +

+ +
  1. $user = $gdata->retrieveUser('foo');
  2. +
  3. $user->login->password = '••••••••';
  4. +
  5. $user = $user->save();
+ + +

+ Note that it is not possible to recover a password in this + manner as stored passwords are not made available via the + Provisioning API for security reasons. +

+
+ +

Forcing a user to change their password

+ + +

+ A user can be forced to change their password at their + next login by setting the + login->changePasswordAtNextLogin property to + TRUE. +

+ +
  1. $user = $gdata->retrieveUser('foo');
  2. +
  3. $user->login->changePasswordAtNextLogin = true;
  4. +
  5. $user = $user->save();
+ + +

+ Similarly, this can be undone by setting the + login->changePasswordAtNextLogin property to + FALSE. +

+
+ +

Suspending a user account

+ + +

+ Users can be restricted from logging in without deleting + their user account by instead + suspending their user account. + Accounts can be suspended or restored by using the + suspendUser() and + restoreUser() convenience methods: +

+ +
  1. $gdata->suspendUser('foo');
  2. +
  3. $gdata->restoreUser('foo');
+ + +

+ Alternatively, you can set the UserEntry's + login->suspended property to + TRUE. +

+ +
  1. $user = $gdata->retrieveUser('foo');
  2. +
  3. $user->login->suspended = true;
  4. +
  5. $user = $user->save();
+ + +

+ To restore the user's access, set the + login->suspended property to + FALSE. +

+
+ +

Granting administrative rights

+ + +

+ Users can be granted the ability to administer your domain + by setting their login->admin property to + TRUE. +

+ +
  1. $user = $gdata->retrieveUser('foo');
  2. +
  3. $user->login->admin = true;
  4. +
  5. $user = $user->save();
+ + +

+ And as expected, setting a user's login->admin + property to FALSE revokes their + administrative rights. +

+
+
+ +

Deleting user accounts

+ + +

+ Deleting a user account to which you already hold a UserEntry + is a simple as calling delete() on that + entry. +

+ +
  1. $user = $gdata->retrieveUser('foo');
  2. +
  3. $user->delete();
+ + +

+ If you do not have access to a UserEntry object for an + account, use the deleteUser() convenience method. +

+ +
  1. $gdata->deleteUser('foo');
+ +
+
+ +

Interacting with nicknames

+ + +

+ Nicknames serve as email aliases for existing users. Each nickname + contains precisely two key properties: its name and its owner. Any + email addressed to a nickname is forwarded to the user who owns + that nickname. +

+ +

+ Nicknames are represented as an instances of + Zend_Gdata_Gapps_NicknameEntry. +

+ +

Creating a nickname

+ + +

+ Nicknames can be created by calling the + createNickname() convenience method: +

+ +
  1. $gdata->createNickname('foo', 'bar');
+ + +

+ Nicknames can also be created by instantiating NicknameEntry, + providing the nickname with a name and an owner, then calling + insertNickname() on a service object to upload + the entry to the server. +

+ +
  1. $nickname = $gdata->newNicknameEntry();
  2. +
  3. $nickname->login = $gdata->newLogin('foo');
  4. +
  5. $nickname->nickname = $gdata->newNickname('bar');
  6. +
  7. $nickname = $gdata->insertNickname($nickname);
+ +
+ +

Retrieving a nickname

+ + +

+ Nicknames can be retrieved by calling the + retrieveNickname() convenience method. This will + return NULL if a user is not found. +

+ +
  1. $nickname = $gdata->retrieveNickname('bar');
  2. +
  3.  
  4. +
  5. echo 'Nickname: ' . $nickname->nickname->name . "\n";
  6. +
  7. echo 'Owner: ' . $nickname->login->username . "\n";
+ + +

+ Individual nicknames can also be retrieved by creating an + instance of Zend_Gdata_Gapps_NicknameQuery, setting its + nickname property to equal the nickname that is to be + retrieved, and calling getNicknameEntry() on a + service object with that query. +

+ +
  1. $query = $gdata->newNicknameQuery('bar');
  2. +
  3. $nickname = $gdata->getNicknameEntry($query);
  4. +
  5.  
  6. +
  7. echo 'Nickname: ' . $nickname->nickname->name . "\n";
  8. +
  9. echo 'Owner: ' . $nickname->login->username . "\n";
+ + +

+ As with users, if no corresponding nickname is found a + ServiceException will be thrown with an error code of + Zend_Gdata_Gapps_Error::ENTITY_DOES_NOT_EXIST. Again, these + will be discussed in the exceptions chapter. +

+
+ +

Retrieving all nicknames for a user

+ + +

+ To retrieve all nicknames associated with a given user, call + the convenience method retrieveNicknames(). +

+ +
  1. $feed = $gdata->retrieveNicknames('foo');
  2. +
  3.  
  4. +
  5. foreach ($feed as $nickname) {
  6. +
  7.     echo '  * ' . $nickname->nickname->name . "\n";
  8. +
  9. }
+ + +

+ This will create a Zend_Gdata_Gapps_NicknameFeed object which + holds each nickname associated with the specified user. +

+ +

+ Alternatively, create a new Zend_Gdata_Gapps_NicknameQuery, + set its username property to the desired user, and submit the + query by calling getNicknameFeed() on a service + object. +

+ +
  1. $query = $gdata->newNicknameQuery();
  2. +
  3. $query->setUsername('foo');
  4. +
  5. $feed = $gdata->getNicknameFeed($query);
  6. +
  7.  
  8. +
  9. foreach ($feed as $nickname) {
  10. +
  11.     echo '  * ' . $nickname->nickname->name . "\n";
  12. +
  13. }
+ +
+ +

Retrieving all nicknames in a domain

+ + +

+ To retrieve all nicknames in a feed, simply call the + convenience method retrieveAllNicknames() +

+ +
  1. $feed = $gdata->retrieveAllNicknames();
  2. +
  3.  
  4. +
  5. foreach ($feed as $nickname) {
  6. +
  7.     echo '  * ' . $nickname->nickname->name . ' => ' .
  8. +
  9.         $nickname->login->username . "\n";
  10. +
  11. }
+ + +

+ This will create a Zend_Gdata_Gapps_NicknameFeed object which + holds each nickname on the domain. +

+ +

+ Alternatively, call getNicknameFeed() on a + service object with no arguments. +

+ +
  1. $feed = $gdata->getNicknameFeed();
  2. +
  3.  
  4. +
  5. foreach ($feed as $nickname) {
  6. +
  7.     echo '  * ' . $nickname->nickname->name . ' => ' .
  8. +
  9.         $nickname->login->username . "\n";
  10. +
  11. }
+ +
+ +

Deleting a nickname

+ + +

+ Deleting a nickname to which you already hold a NicknameEntry + for is a simple as calling delete() on that + entry. +

+ +
  1. $nickname = $gdata->retrieveNickname('bar');
  2. +
  3. $nickname->delete();
+ + +

+ For nicknames which you do not hold a NicknameEntry for, use + the deleteNickname() convenience method. +

+ +
  1. $gdata->deleteNickname('bar');
+ +
+
+ +

Interacting with groups

+ + +

+ Google Groups allows people to post messages like an email list. Google + is depreciating the Email List API. Google Groups provides some neat + features like nested groups and group owners. If you want to start + a new email lst, it is advisable to use Google Groups instead. + Google's Email List is not compatible with Google Groups. So if you + create an email list, it will not show up as a group. The opposite is + true as well. +

+ +

+ Each group on a domain is represented as an instance of + Zend_Gdata_Gapps_GroupEntry. +

+ +

Creating a group

+ + +

+ Groups can be created by calling the + createGroup() convenience method: +

+ +
  1. $gdata->createGroup('friends', 'The Friends Group');
+ + +

+ Groups can also be created by instantiating + GroupEntry, providing a group id and name for the group, + then calling insertGroup() on a service + object to upload the entry to the server. +

+ +
  1. $group = $gdata->newGroupEntry();
  2. +
  3.  
  4. +
  5. $properties[0] = $this->newProperty();
  6. +
  7. $properties[0]->name = 'groupId';
  8. +
  9. $properties[0]->value = 'friends';
  10. +
  11. $properties[1] = $this->newProperty();
  12. +
  13. $properties[1]->name = 'groupName';
  14. +
  15. $properties[1]->value = 'The Friends Group';
  16. +
  17.  
  18. +
  19. $group->property = $properties;
  20. +
  21.  
  22. +
  23. $group = $gdata->insertGroup($group);
+ +
+ +

Retrieving an individual group

+ + +

+ To retrieve an individual group, call the + retrieveGroup() convenience method: +

+ +
  1. $entry = $gdata->retrieveGroup('friends');
  2. +
  3.  
  4. +
  5. foreach ($entry->property as $p) {
  6. +
  7.     echo "Property Name: " . $p->name;
  8. +
  9.     echo "\nProperty Value: " . $p->value . "\n\n";
  10. +
  11. }
+ + +

+ This will create a Zend_Gdata_Gapps_GroupEntry + object which holds the properties about the group. +

+ +

+ Alternatively, create a new Zend_Gdata_Gapps_GroupQuery, + set its groupId property to the desired group id, and + submit the query by calling getGroupEntry() + on a service object. +

+ +
  1. $query = $gdata->newGroupQuery();
  2. +
  3. $query->setGroupId('friends');
  4. +
  5. $entry = $gdata->getGroupEntry($query);
  6. +
  7.  
  8. +
  9. foreach ($entry->property as $p) {
  10. +
  11.     echo "Property Name: " . $p->name;
  12. +
  13.     echo "\nProperty Value: " . $p->value . "\n\n";
  14. +
  15. }
+ +
+ +

Retrieving all groups in a domain

+ + +

+ To retrieve all groups in a domain, call the convenience + method retrieveAllGroups(). +

+ +
  1. $feed = $gdata->retrieveAllGroups();
  2. +
  3.  
  4. +
  5. foreach ($feed->entry as $entry) {
  6. +
  7.     foreach ($entry->property as $p) {
  8. +
  9.         echo "Property Name: " . $p->name;
  10. +
  11.         echo "\nProperty Value: " . $p->value . "\n\n";
  12. +
  13.     }
  14. +
  15.     echo "\n\n";
  16. +
  17. }
+ + +

+ This will create a Zend_Gdata_Gapps_GroupFeed + object which holds each group on the domain. +

+ +

+ Alternatively, call getGroupFeed() on a + service object with no arguments. +

+ +
  1. $feed = $gdata->getGroupFeed();
  2. +
  3.  
  4. +
  5. foreach ($feed->entry as $entry) {
  6. +
  7.     foreach ($entry->property as $p) {
  8. +
  9.         echo "Property Name: " . $p->name;
  10. +
  11.         echo "\nProperty Value: " . $p->value . "\n\n";
  12. +
  13.     }
  14. +
  15.     echo "\n\n";
  16. +
  17. }
+ +
+ +

Deleting a group

+ + +

+ To delete a group, call the deleteGroup() convenience + method: +

+ +
  1. $gdata->deleteGroup('friends');
+ +
+ +

Updating a group

+ + +

+ Groups can be updated by calling the + updateGroup() convenience method: +

+ +
  1. $gdata->updateGroup('group-id-here', 'Group Name Here');
+ + +

+ The first parameter is required. The second, third and fourth parameter, + representing the group name, group descscription, and email permission, + respectively are optional. Setting any of these optional parameters + to null will not update that item. +

+
+ +

Retrieving all groups to which a person is a member

+ + +

+ To retrieve all groups to which a particular person is a + member, call the retrieveGroups() + convenience method: +

+ +
  1. $feed = $gdata->retrieveGroups('baz@somewhere.com');
  2. +
  3.  
  4. +
  5. foreach ($feed->entry as $entry) {
  6. +
  7.     foreach ($entry->property as $p) {
  8. +
  9.         echo "Property Name: " . $p->name;
  10. +
  11.         echo "\nProperty Value: " . $p->value . "\n\n";
  12. +
  13.     }
  14. +
  15.     echo "\n\n";
  16. +
  17. }
+ + +

+ This will create a Zend_Gdata_Gapps_GroupFeed + object which holds each group associated with the specified member. +

+ +

+ Alternatively, create a new Zend_Gdata_Gapps_GroupQuery, + set its member property to the desired email address, and + submit the query by calling getGroupFeed() + on a service object. +

+ +
  1. $query = $gdata->newGroupQuery();
  2. +
  3. $query->setMember('baz@somewhere.com');
  4. +
  5. $feed = $gdata->getGroupFeed($query);
  6. +
  7.  
  8. +
  9. foreach ($feed->entry as $entry) {
  10. +
  11.     foreach ($entry->property as $p) {
  12. +
  13.         echo "Property Name: " . $p->name;
  14. +
  15.         echo "\nProperty Value: " . $p->value . "\n\n";
  16. +
  17.     }
  18. +
  19.     echo "\n\n";
  20. +
  21. }
+ +
+
+ +

Interacting with group members

+ + +

+ Each member subscribed to a group is represented by an + instance of Zend_Gdata_Gapps_MemberEntry. + Through this class, individual recipients can be added and removed + from groups. +

+ +

Adding a member to a group

+ + +

+ To add a member to a group, simply call the + addMemberToGroup() convenience method: +

+ +
  1. $gdata->addMemberToGroup('bar@somewhere.com', 'friends');
+ +
+ +

Check to see if member belongs to group

+ + +

+ To check to see if member belongs to group, simply call the + isMember() convenience method: +

+ +
  1. $isMember = $gdata->isMember('bar@somewhere.com', 'friends');
  2. +
  3. var_dump($isMember);
+ + +

+ The method returns a boolean value. If the member belongs to the + group specified, the method returns true, else it returns false. +

+
+ +

Removing a member from a group

+ + +

+ To remove a member from a group, call the + removeMemberFromGroup() convenience + method: +

+ +
  1. $gdata->removeMemberFromGroup('baz', 'friends');
+ +
+ +

Retrieving the list of members to a group

+ + +

+ The convenience method retrieveAllMembers() + can be used to retrieve the list of members of a group: +

+ +
  1. $feed = $gdata->retrieveAllMembers('friends');
  2. +
  3.  
  4. +
  5. foreach ($feed as $member) {
  6. +
  7.     foreach ($member->property as $p) {
  8. +
  9.         echo "Property Name: " . $p->name;
  10. +
  11.         echo "\nProperty Value: " . $p->value . "\n\n";
  12. +
  13.     }
  14. +
  15. }
+ + +

+ Alternatively, construct a new MemberQuery, set its groupId + property to match the desired group id, and call + getMemberFeed() on a service object. +

+ +
  1. $query = $gdata->newMemberQuery();
  2. +
  3. $query->setGroupId('friends');
  4. +
  5. $feed = $gdata->getMemberFeed($query);
  6. +
  7.  
  8. +
  9. foreach ($feed as $member) {
  10. +
  11.     foreach ($member->property as $p) {
  12. +
  13.         echo "Property Name: " . $p->name;
  14. +
  15.         echo "\nProperty Value: " . $p->value . "\n\n";
  16. +
  17.     }
  18. +
  19. }
+ + +

+ This will create a Zend_Gdata_Gapps_MemberFeed + object which holds each member for the selected group. +

+
+
+ +

Interacting with group owners

+ + +

+ Each owner associated with a group is represented by an + instance of Zend_Gdata_Gapps_OwnerEntry. + Through this class, individual owners can be added and removed + from groups. +

+ +

Adding an owner to a group

+ + +

+ To add an owner to a group, simply call the + addOwnerToGroup() convenience method: +

+ +
  1. $gdata->addOwnerToGroup('bar@somewhere.com', 'friends');
+ +
+ +

Retrieving the list of the owner of a group

+ + +

+ The convenience method retrieveGroupOwners() + can be used to retrieve the list of the owners of a group: +

+ +
  1. $feed = $gdata->retrieveGroupOwners('friends');
  2. +
  3.  
  4. +
  5. foreach ($feed as $owner) {
  6. +
  7.     foreach ($owner->property as $p) {
  8. +
  9.         echo "Property Name: " . $p->name;
  10. +
  11.         echo "\nProperty Value: " . $p->value . "\n\n";
  12. +
  13.     }
  14. +
  15. }
+ + +

+ Alternatively, construct a new OwnerQuery, set its groupId + property to match the desired group id, and call + getOwnerFeed() on a service object. +

+ +
  1. $query = $gdata->newOwnerQuery();
  2. +
  3. $query->setGroupId('friends');
  4. +
  5. $feed = $gdata->getOwnerFeed($query);
  6. +
  7.  
  8. +
  9. foreach ($feed as $owner) {
  10. +
  11.     foreach ($owner->property as $p) {
  12. +
  13.         echo "Property Name: " . $p->name;
  14. +
  15.         echo "\nProperty Value: " . $p->value . "\n\n";
  16. +
  17.     }
  18. +
  19. }
+ + +

+ This will create a Zend_Gdata_Gapps_OwnerFeed + object which holds each member for the selected group. +

+
+ +

Check to see if an email is the owner of a group

+ + +

+ To check to see if an email is the owner of a group, simply call + the isOwner() convenience method: +

+ +
  1. $isOwner = $gdata->isOwner('bar@somewhere.com', 'friends');
  2. +
  3. var_dump($isOwner);
+ + +

+ The method returns a boolean value. If the email is the owner of + the group specified, the method returns true, else it returns false. +

+
+ +

Removing an owner from a group

+ + +

+ To remove an owner from a group, call the + removeOwnerFromGroup() convenience + method: +

+ +
  1. $gdata->removeOwnerFromGroup('baz@somewhere.com', 'friends');
+ +
+
+ +

Interacting with email lists

+ + +

+ Email lists allow several users to retrieve email addressed to a + single email address. Users do not need to be a + member of this domain in order to subscribe to an email list + provided their complete email address (including domain) is used. +

+ +

+ Each email list on a domain is represented as an instance of + Zend_Gdata_Gapps_EmailListEntry. +

+ +

Creating an email list

+ + +

+ Email lists can be created by calling the + createEmailList() convenience method: +

+ +
  1. $gdata->createEmailList('friends');
+ + +

+ Email lists can also be created by instantiating + EmailListEntry, providing a name for the list, then calling + insertEmailList() on a service object to upload + the entry to the server. +

+ +
  1. $list = $gdata->newEmailListEntry();
  2. +
  3. $list->emailList = $gdata->newEmailList('friends');
  4. +
  5. $list = $gdata->insertEmailList($list);
+ +
+ +

Retrieving all email lists to which a recipient is subscribed

+ + +

+ To retrieve all email lists to which a particular recipient is + subscribed, call the retrieveEmailLists() + convenience method: +

+ +
  1. $feed = $gdata->retrieveEmailLists('baz@somewhere.com');
  2. +
  3.  
  4. +
  5. foreach ($feed as $list) {
  6. +
  7.     echo '  * ' . $list->emailList->name . "\n";
  8. +
  9. }
+ + +

+ This will create a Zend_Gdata_Gapps_EmailListFeed object + which holds each email list associated with the specified recipient. +

+ +

+ Alternatively, create a new Zend_Gdata_Gapps_EmailListQuery, + set its recipient property to the desired email address, and + submit the query by calling getEmailListFeed() on + a service object. +

+ +
  1. $query = $gdata->newEmailListQuery();
  2. +
  3. $query->setRecipient('baz@somewhere.com');
  4. +
  5. $feed = $gdata->getEmailListFeed($query);
  6. +
  7.  
  8. +
  9. foreach ($feed as $list) {
  10. +
  11.     echo '  * ' . $list->emailList->name . "\n";
  12. +
  13. }
+ +
+ +

Retrieving all email lists in a domain

+ + +

+ To retrieve all email lists in a domain, call the convenience + method retrieveAllEmailLists(). +

+ +
  1. $feed = $gdata->retrieveAllEmailLists();
  2. +
  3.  
  4. +
  5. foreach ($feed as $list) {
  6. +
  7.     echo '  * ' . $list->emailList->name . "\n";
  8. +
  9. }
+ + +

+ This will create a Zend_Gdata_Gapps_EmailListFeed object + which holds each email list on the domain. +

+ +

+ Alternatively, call getEmailListFeed() on a + service object with no arguments. +

+ +
  1. $feed = $gdata->getEmailListFeed();
  2. +
  3.  
  4. +
  5. foreach ($feed as $list) {
  6. +
  7.     echo '  * ' . $list->emailList->name . "\n";
  8. +
  9. }
+ +
+ +

Deleting an email list

+ + +

+ To delete an email list, call the deleteEmailList() + convenience method: +

+ +
  1. $gdata->deleteEmailList('friends');
+ +
+
+ +

Interacting with email list recipients

+ + +

+ Each recipient subscribed to an email list is represented by an + instance of Zend_Gdata_Gapps_EmailListRecipient. Through this + class, individual recipients can be added and removed from email + lists. +

+ +

Adding a recipient to an email list

+ + +

+ To add a recipient to an email list, simply call the + addRecipientToEmailList() convenience method: +

+ +
  1. $gdata->addRecipientToEmailList('bar@somewhere.com', 'friends');
+ +
+ +

Retrieving the list of subscribers to an email list

+ + +

+ The convenience method retrieveAllRecipients() + can be used to retrieve the list of subscribers to an email list: +

+ +
  1. $feed = $gdata->retrieveAllRecipients('friends');
  2. +
  3.  
  4. +
  5. foreach ($feed as $recipient) {
  6. +
  7.     echo '  * ' . $recipient->who->email . "\n";
  8. +
  9. }
+ + +

+ Alternatively, construct a new EmailListRecipientQuery, set + its emailListName property to match the desired email list, + and call getEmailListRecipientFeed() on a service + object. +

+ +
  1. $query = $gdata->newEmailListRecipientQuery();
  2. +
  3. $query->setEmailListName('friends');
  4. +
  5. $feed = $gdata->getEmailListRecipientFeed($query);
  6. +
  7.  
  8. +
  9. foreach ($feed as $recipient) {
  10. +
  11.     echo '  * ' . $recipient->who->email . "\n";
  12. +
  13. }
+ + +

+ This will create a Zend_Gdata_Gapps_EmailListRecipientFeed + object which holds each recipient for the selected email list. +

+
+ +

Removing a recipient from an email list

+ + +

+ To remove a recipient from an email list, call the + removeRecipientFromEmailList() convenience + method: +

+ +
  1. $gdata->removeRecipientFromEmailList('baz@somewhere.com', 'friends');
+ +
+
+ +

Handling errors

+ + +

+ In addition to the standard suite of exceptions thrown by + Zend_Gdata, requests using the Provisioning + API may also throw a + Zend_Gdata_Gapps_ServiceException. These exceptions + indicate that a API specific error occurred which prevents the + request from completing. +

+ +

+ Each ServiceException instance may hold one or more Error objects. + Each of these objects contains an error code, reason, and + (optionally) the input which triggered the exception. A complete + list of known error codes is provided in Zend Framework's API + documentation under Zend_Gdata_Gapps_Error. Additionally, the + authoritative error list is available online at » Google + Apps Provisioning API V2.0 Reference: Appendix D. +

+ +

+ While the complete list of errors received is available within + ServiceException as an array by calling getErrors(), + often it is convenient to know if one specific error occurred. For + these cases the presence of an error can be determined by calling + hasError(). +

+ +

+ The following example demonstrates how to detect if a requested + resource doesn't exist and handle the fault gracefully: +

+ +
  1. function retrieveUser ($username) {
  2. +
  3.     $query = $gdata->newUserQuery($username);
  4. +
  5.     try {
  6. +
  7.         $user = $gdata->getUserEntry($query);
  8. +
  9.     } catch (Zend_Gdata_Gapps_ServiceException $e) {
  10. +
  11.         // Set the user to null if not found
  12. +
  13.         if ($e->hasError(Zend_Gdata_Gapps_Error::ENTITY_DOES_NOT_EXIST)) {
  14. +
  15.             $user = null;
  16. +
  17.         } else {
  18. +
  19.             throw $e;
  20. +
  21.         }
  22. +
  23.     }
  24. +
  25.     return $user;
  26. +
  27. }
+ +
+
+
+ + + + + + + + + +
+ Using Google Spreadsheets + + + + +
+
+ +
+ + \ No newline at end of file -- cgit v1.2.3