Skip to content

Class GContactGroups

Stefan Kientzler edited this page Apr 26, 2023 · 3 revisions

Full name:     \SKien\Google\GContactGroups


Class to manage the contact groups of a google account.

This class encapsulates the following Google People API resources:

  • contactGroups
  • contactGroups.members

If one of the methods that calls the google API fails (if it returns false), the last responsecode and furter informations can be retrieved through following methods of the GClient instance this object was created with:

  • $oClient->getLastResponseCode()
  • $oClient->getLastError()
  • $oClient->getLastStatus()

See Also:

Constants

Constant Description
GF_CLIENT_DATA The group's client data
GF_GROUP_TYPE The contact group type
GF_MEMBER_COUNT The total number of contacts in the group irrespective of max members in specified in the request
GF_METADATA The metadata about a contact group
GF_NAME name, formattedName, resourceName
GT_ALL_CONTACT_GROUPS All available contact groups (User- and system groups)
GT_USER_CONTACT_GROUPS User defined contact group
GT_SYSTEM_CONTACT_GROUPS System defined contact group
DATA_LIST full data list
RES_LIST list as associative array resourceName -> groupName
GRP_STARRED system group 'starred'
GRP_CHAT_BUDDIES system group 'chatBuddies'
GRP_ALL system group 'all'
GRP_MY_CONTACTS system group 'myContacts'
GRP_FRIENDS system group 'friends'
GRP_FAMILY system group 'family'
GRP_COWORKERS system group 'coworkers'
GRP_BLOCKED system group 'blocked'

Overview

Method Description
__construct Create an instance and pass the client to use for the API requests.
addContactsToGroup Add one or more contacts to the specified group.
addGroupFields Add groupFields for next request.
createGroup Create a new contact group.
deleteGroup Delete the contact group specified by the resourceName.
getGroup Get whole group information.
getGroupResourceName Get the resourceName for a named contact group.
list Get the whole list of the contact groups.
removeContactsFromGroup Remove one or more contacts from the specified group.
setPageSize Set the pagesize for reading lists.
updateGroup Update the groupName for the group specified by the resourceName.

Methods

__construct

Create an instance and pass the client to use for the API requests.

public GContactGroups::__construct(\SKien\Google\GClient $oClient)

Parameters:

Parameter Type Description
oClient \SKien\Google\GClient

[go to top]


addContactsToGroup

Add one or more contacts to the specified group.

public GContactGroups::addContactsToGroup(string $strGroupResourceName, string[] $aContactResourceNames) : array|false

Parameters:

Parameter Type Description
strGroupResourceName string
aContactResourceNames string[]

Return Type: array|false

See Also:

[go to top]


addGroupFields

Add groupFields for next request.

public GContactGroups::addGroupFields(mixed $fields) : void

Can be called multiple and/or by passing an array of groupFields. All const self::GF_xxxx can be specified. Normally the groupFields parameter is left blank, which means that all groupFields except GF_CLIENT_DATA are taken into account.

Parameters:

Parameter Type Description
fields mixed

[go to top]


createGroup

Create a new contact group.

public GContactGroups::createGroup(string $strGroupName) : array|false

The name must be unique to the users contact groups. Attempting to create a group with a duplicate name results in a 409 response code.

Parameters:

Parameter Type Description
strGroupName string

Return Type: array|false

See Also:

[go to top]


deleteGroup

Delete the contact group specified by the resourceName.

public GContactGroups::deleteGroup(string $strResourceName, bool $bDeleteContacts = false) : bool

If the param $bDeleteContacts is set to true, ALL contacts that are asigned to the group to delete will be deleted to!

Parameters:

Parameter Type Description
strResourceName string
bDeleteContacts bool set to true, if all groupmembers should be deleted

Return Type: bool

true on success, false on error.

See Also:

[go to top]


getGroup

Get whole group information.

public GContactGroups::getGroup(string $strResourceName, int $iMaxMembers) : array|false

Parameters:

Parameter Type Description
strResourceName string
iMaxMembers int

Return Type: array|false

See Also:

[go to top]


getGroupResourceName

Get the resourceName for a named contact group.

public GContactGroups::getGroupResourceName(string $strGroupName) : string|false

If no group with requested name found, the method will return an empty string.

Parameters:

Parameter Type Description
strGroupName string

Return Type: string|false

resourceName or false in case of an error

[go to top]


list

Get the whole list of the contact groups.

public GContactGroups::list(string $strGroupType = self::GT_ALL_CONTACT_GROUPS, int $iListType = self::RES_LIST) : array|false

The type of the groups to list (All, User or System) can be specified by the $strGroupType parameter.

The content of the result array can be specified with the $iListType parameter.

  • self::RES_LIST: all groups as associative array ressourceName -> groupName.
  • self::DATA_LIST: an array of all ContactGroup - objects.

Parameters:

Parameter Type Description
strGroupType string use one of the self::GT_xxx constants
iListType int content of the result array (self::RES_LIST or self::DATA_LIST)

Return Type: array|false

See Also:

[go to top]


removeContactsFromGroup

Remove one or more contacts from the specified group.

public GContactGroups::removeContactsFromGroup(string $strGroupResourceName, string[] $aContactResourceNames) : array|false

Parameters:

Parameter Type Description
strGroupResourceName string
aContactResourceNames string[]

Return Type: array|false

See Also:

[go to top]


setPageSize

Set the pagesize for reading lists.

public GContactGroups::setPageSize(int $iPageSize) : void

May be limited to the max. pagesize for the request.

Parameters:

Parameter Type Description
iPageSize int

[go to top]


updateGroup

Update the groupName for the group specified by the resourceName.

public GContactGroups::updateGroup(string $strResourceName, string $strGroupName) : array|false

The new name must be unique to the users contact groups. Attempting to rename a group with a duplicate name results in a 409 response code.

Parameters:

Parameter Type Description
strResourceName string
strGroupName string

Return Type: array|false

See Also:

[go to top]


Clone this wiki locally