-
Notifications
You must be signed in to change notification settings - Fork 1
Class GContacts
Full name: \SKien\Google\GContacts
Class to manage the contacts of a google account.
This class encapsulates the following Google People API resources:
- people
- people.connections
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:
- \SKien\Google\GClient::getLastResponseCode()
- \SKien\Google\GClient::getLastError()
- \SKien\Google\GClient::getLastStatus()
- https://developers.google.com/people/api/rest/v1/people
- https://developers.google.com/people/api/rest/v1/people.connections
| Constant | Description |
|---|---|
CONTACTS |
full access to the users contacts |
CONTACTS_READONLY |
readonly access to the users contacts |
CONTACTS_OTHER_READONLY |
readonly access to the users other contacts |
SO_LAST_MODIFIED_ASCENDING |
Sort people by when they were changed; older entries first. |
SO_LAST_MODIFIED_DESCENDING |
Sort people by when they were changed; newer entries first. |
SO_FIRST_NAME_ASCENDING |
Sort people by first name. |
SO_LAST_NAME_ASCENDING |
Sort people by last name. |
DEF_DETAIL_PERSON_FIELDS |
the default personFields for detail view |
DEF_LIST_PERSON_FIELDS |
the default personFields for detail view |
| Method | Description |
|---|---|
| __construct | Create instance an pass the clinet for the requests. |
| addPersonFields | Add personFields/readMask for next request. |
| createContact | Creates a new contact. |
| deleteContact | Delete the requested contact. |
| deleteContactPhoto | Delete contact photo for given contact. |
| getContact | Get the contact specified by its resourceName. |
| list | Get the whole contact list. |
| search | Search within the contacts. |
| setContactPhoto | Set contact photo from base64 encoded image data. |
| setContactPhotoFile | Set contact photo from image file. |
| setContactStarred | Set or unset the 'starred' mark for the specified contact. |
| setPageSize | Set the pagesize for reading lists. |
| updateContact | Updates an existing contact specified by resourceName. |
Create instance an pass the clinet for the requests.
public GContacts::__construct(\SKien\Google\GClient $oClient)Parameters:
| Parameter | Type | Description |
|---|---|---|
oClient |
\SKien\Google\GClient |
Add personFields/readMask for next request.
public GContacts::addPersonFields(mixed $fields) : voidCan be called multiple and/or by passing an array of personFields. All
const GContact::PF_xxxx can be specified.
If no personFields specified before an API call, as default setting
-
self::DEF_DETAIL_PERSON_FIELDSfor the getContact() and -
self::DEF_LIST_PERSON_FIELDSfor the list() and search() call is used
Parameters:
| Parameter | Type | Description |
|---|---|---|
fields |
mixed |
Creates a new contact.
public GContacts::createContact(\SKien\Google\GContact $oContact) : \SKien\Google\GContact|falseParameters:
| Parameter | Type | Description |
|---|---|---|
oContact |
\SKien\Google\GContact |
Return Type: \SKien\Google\GContact|false
See Also:
Delete the requested contact.
public GContacts::deleteContact(string $strResourceName) : boolParameters:
| Parameter | Type | Description |
|---|---|---|
strResourceName |
string |
Return Type: bool
See Also:
Delete contact photo for given contact.
public GContacts::deleteContactPhoto(string $strResourceName) : boolParameters:
| Parameter | Type | Description |
|---|---|---|
strResourceName |
string |
Return Type: bool
See Also:
Get the contact specified by its resourceName.
public GContacts::getContact(string $strResourceName) : \SKien\Google\GContact|falseNote that only the person fields specified with addPersonFields() are included
in the result.
Parameters:
| Parameter | Type | Description |
|---|---|---|
strResourceName |
string |
Return Type: \SKien\Google\GContact|false
See Also:
- \SKien\Google\GContact::addPersonFields()
- https://developers.google.com/people/api/rest/v1/people/get
Get the whole contact list.
public GContacts::list(string $strSortOrder = self::SO_LAST_NAME_ASCENDING, string $strGroupResourceName = '') : array|falseParameters:
| Parameter | Type | Description |
|---|---|---|
strSortOrder |
string | one of the self::SO_xxx constants |
strGroupResourceName |
string |
Return Type: array|false
See Also:
Search within the contacts.
public GContacts::search(string $strQuery) : array|falseThe query matches on a contact's names, nickNames, emailAddresses,
phoneNumbers, and organizations fields. The search for phone numbers only
works, if leading '+' and contained '(', ')' or spaces are omitted in the query!
The query is used to match prefix phrases of the fields on a person.
For example, a person with name "foo name" matches queries such as "f", "fo",
"foo", "foo n", "nam", etc., but not "oo n".
Note: The count of contacts, the search request returns is limitetd to the pageSize (which is limited itself to max. 30 at all). If there are more contacts in the list that matches the query, unfortunately NO further information about that additional contacts - and how many - are available!
Parameters:
| Parameter | Type | Description |
|---|---|---|
strQuery |
string | the query to search for |
Return Type: array|false
See Also:
Set contact photo from base64 encoded image data.
public GContacts::setContactPhoto(string $strResourceName, string $blobPhoto) : boolParameters:
| Parameter | Type | Description |
|---|---|---|
strResourceName |
string | |
blobPhoto |
string | base64 encoded image |
Return Type: bool
See Also:
Set contact photo from image file.
public GContacts::setContactPhotoFile(string $strResourceName, string $strFilename) : boolSupported types are JPG, PNG, GIF and BMP.
Parameters:
| Parameter | Type | Description |
|---|---|---|
strResourceName |
string | |
strFilename |
string |
Return Type: bool
See Also:
Set or unset the 'starred' mark for the specified contact.
public GContacts::setContactStarred(string $strResourceName, bool $bSetStarred = true) : boolThe 'starred' mark just means, the contact belongs to the system group contactGroups/starred.
Parameters:
| Parameter | Type | Description |
|---|---|---|
strResourceName |
string | |
bSetStarred |
bool |
Return Type: bool
See Also:
- \SKien\Google\GContactGroups::addContactsToGroup()
- \SKien\Google\GContactGroups::removeContactsFromGroup()
Set the pagesize for reading lists.
public GContacts::setPageSize(int $iPageSize) : voidMay be limited to the max. pgaesize for the request.
- contact list: max. pagesize is 1000
- search: max. pagesize is 30
Parameters:
| Parameter | Type | Description |
|---|---|---|
iPageSize |
int |
Updates an existing contact specified by resourceName.
public GContacts::updateContact(string $strResourceName, \SKien\Google\GContact $oContact) : \SKien\Google\GContact|falseTo prevent the user from data loss, this request fails with an 400 response code, if the contact has changed on the server, since it was loaded. Reload the data from the server and make the changes again!
Parameters:
| Parameter | Type | Description |
|---|---|---|
strResourceName |
string | |
oContact |
\SKien\Google\GContact |
Return Type: \SKien\Google\GContact|false
See Also:
build with phpDocumentor 3 using template phpdoc2githubwiki / (2023-04-26)