Skip to content

Class GContact

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

Full name:     \SKien\Google\GContact


This class represents one single contact/person within the google contacts.

See Also:

Constants

Constant Description
PF_ADDRESSES array of all available addresses
PF_AGE_RANGES array of the persons age ranges: one of the self::AR_xxx constants
PF_BIOGRAPHIES array - singleton with the biographie (usually simply containes the notes to a person)
PF_BIRTHDAYS array - singleton containing the birthday
PF_CALENDAR_URLS array with a person's calendar URLs.
PF_CLIENT_DATA array with arbitrary client data that is populated by clients
PF_COVER_PHOTOS Array with a person's cover photos. A large image shown on the person's profile page
PF_EMAIL_ADDRESSES Array with a person's email addresses
PF_EVENTS Array with events related to the person
PF_EXTERNAL_IDS Array of identifiers from external entities related to the person
PF_GENDERS Array - singleton contains the gender of the person (male, female, unspecified, userdefined)
PF_IM_CLIENTS Array with the person's instant messaging clients
PF_INTERESTS Array with the person's insterests
PF_LOCALES Array with the person's locale preferences (IETF BCP 47 language tag)
PF_LOCATIONS Array with the person's locations
PF_MEMBERSHIPS Array containing the person's memberships to groups
PF_METADATA The metadata about a person
PF_MISC_KEYWORDS Array with miscellaneous keywords to the person
PF_NAMES Array - singleton containuing all names (except nicknames) of the person
PF_NICKNAMES Array with the person's nicknames
PF_OCCUPATIONS Array with the person's occupations
PF_ORGANIZATIONS Array with the person's past or current organizations. Overlapping date ranges are permitted
PF_PHONE_NUMBERS Array containing all of the person's phone numbers
PF_PHOTOS Array with the person's photos. Pictures shown next to the person's name
PF_RELATIONS Array with the person's relations to another person.
PF_SIP_ADDRESSES Array with a person's SIP addresses (Session Initial Protocol addresses)
PF_SKILLS Array containing the skills that the person has.
PF_URLS Array with the person's associated URLs. (Homepage, work, blog, ...)
PF_USER_DEFINED Arbitrary user data that is populated by the end users
AR_UNSPECIFIED Age range unspecified
AR_LESS_THAN_EIGHTEEN Age range: Younger than eighteen.
AR_EIGHTEEN_TO_TWENTY Age range: Between eighteen and twenty.
AR_TWENTY_ONE_OR_OLDER Age range: Twenty-one and older.
DT_STRING Date type: string
DT_UNIX_TIMESTAMP Date type: unix timestamp
DT_OBJECT Date type: DateTime - Object

Overview

Method Description
__construct
belongsToGroup Checks, if current contact belongs to requested contact group.
createEmpty Create a template object with an empty element for each requested personField - section.
fromArray Create a instance from a array.
fromJSON Create a instance from a fetched JSON contact.
getDateOfBirth Get date of birth.
getDisplayName
getLastModified Get last modification timestamp.
getPrimaryItemIndex Get the index of the primary item of the given personFields.
getResourceName
isPrimaryItem Checks, if given item is marked as primary item.
isStarred Checks, if current contact is starred.
setDateOfBirth Set date of birth.
setMetaData Set the meta data for the contact.
setPrimaryItem Set the primary item for the given personFields.

Methods

__construct

public GContact::__construct(array $aData = null)

Parameters:

Parameter Type Description
aData array

[go to top]


belongsToGroup

Checks, if current contact belongs to requested contact group.

public GContact::belongsToGroup(string $strGroupResourceName) : bool

Parameters:

Parameter Type Description
strGroupResourceName string

Return Type: bool

[go to top]


createEmpty

Create a template object with an empty element for each requested personField - section.

public static GContact::createEmpty(string[] $aPersonFields = null) : \SKien\Google\GContact

Adds empty metadata to the object.

Parameters:

Parameter Type Description
aPersonFields string[]

Return Type: \SKien\Google\GContact

[go to top]


fromArray

Create a instance from a array.

public static GContact::fromArray(array $aData) : \SKien\Google\GContact

Parameters:

Parameter Type Description
aData array

Return Type: \SKien\Google\GContact

[go to top]


fromJSON

Create a instance from a fetched JSON contact.

public static GContact::fromJSON(string $strJSON, string[] $aPersonFields = null) : \SKien\Google\GContact

Parameters:

Parameter Type Description
strJSON string
aPersonFields string[]

Return Type: \SKien\Google\GContact

[go to top]


getDateOfBirth

Get date of birth.

public GContact::getDateOfBirth(int $iType = self::DT_STRING, string $strFormat = 'Y-m-d') : string|int|\DateTime|null

The return type can be specified in the $iTypeparameter:

  • self::DT_STRING (default): Date as String in the format set with `$strFormat`param (default = 'Y-m-d')
  • self::DT_UNIX_TIMESTAMP: Date as unix timestamp
  • self::DT_OBJECT: Date as DateTime object

if the property is not set in the contact method returns:

  • self::DT_STRING: empty string
  • self::DT_UNIX_TIMESTAMP: integer 0
  • self::DT_OBJECT: null

Parameters:

Parameter Type Description
iType int self::DT_STRING (default), self::DT_UNIX_TIMESTAMP or self::DT_OBJECT
strFormat string Date format compliant to DateTime::format() (default 'Y-m-d')

Return Type: string|int|\DateTime|null

See Also:

[go to top]


getDisplayName

public GContact::getDisplayName() : string

Return Type: string

[go to top]


getLastModified

Get last modification timestamp.

public GContact::getLastModified(string $strTimezone = null) : int

Parameters:

Parameter Type Description
strTimezone string valid timezone

Return Type: int

unixtimestamp of last modification

[go to top]


getPrimaryItemIndex

Get the index of the primary item of the given personFields.

public GContact::getPrimaryItemIndex(string $strPersonFields) : int

Parameters:

Parameter Type Description
strPersonFields string

Return Type: int

$iPrimaryIndex -1 if no items found or no item marked as primary

See Also:

[go to top]


getResourceName

public GContact::getResourceName() : string

Return Type: string

[go to top]


isPrimaryItem

Checks, if given item is marked as primary item.

public GContact::isPrimaryItem(array $aItem) : bool

Parameters:

Parameter Type Description
aItem array

Return Type: bool

See Also:

[go to top]


isStarred

Checks, if current contact is starred.

public GContact::isStarred() : bool

The property 'starred' just means, the contact belongs to the system group contactGroups/starred.

Return Type: bool

[go to top]


setDateOfBirth

Set date of birth.

public GContact::setDateOfBirth(string|int|\DateTime $DateOfBirth) : void

Parameters:

Parameter Type Description
DateOfBirth string | int | \DateTime can be string (format YYYY-MM-DD), int (unixtimestamp) or DateTime - object

[go to top]


setMetaData

Set the meta data for the contact.

public GContact::setMetaData(string $strType, string $strID, string $strETag) : void

The server returns a 400 error if person.metadata.sources is not specified for a contact to be updated or if there is no contact source. The server returns a 400 error with reason "failedPrecondition" if person.metadata.sources.etag is different than the contact's etag, which indicates the contact has changed since its data was read. In this case, clients should fetch the latest changes and merge their updates.

Parameters:

Parameter Type Description
strType string
strID string
strETag string

[go to top]


setPrimaryItem

Set the primary item for the given personFields.

public GContact::setPrimaryItem(string $strPersonFields, int $iPrimary) : void

Reset the primary marker for all other items in the same array.

Parameters:

Parameter Type Description
strPersonFields string
iPrimary int

See Also:

[go to top]


Clone this wiki locally