PHP code example of rapidwebltd / php-google-contacts-v3-api

1. Go to this page and download the library: Download rapidwebltd/php-google-contacts-v3-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rapidwebltd / php-google-contacts-v3-api example snippets


$contacts = rapidweb\googlecontacts\factories\ContactFactory::getAll();

var_dump($contacts);

$selfURL = "...";

$contact = rapidweb\googlecontacts\factories\ContactFactory::getBySelfURL($selfURL);

var_dump($contact);

$selfURL = "...";

$contact = rapidweb\googlecontacts\factories\ContactFactory::getBySelfURL($selfURL);

echo $contact->name;
echo $contact->phoneNumber;
echo $contact->email;
echo $contact->content;

$selfURL = "...";

$contact = rapidweb\googlecontacts\factories\ContactFactory::getBySelfURL($selfURL);

var_dump($contact);

$contact->name = 'Test';
$contact->phoneNumber = '07812363789';
$contact->email = '[email protected]';
$contact->content = 'Note for example';

$contactAfterUpdate = rapidweb\googlecontacts\factories\ContactFactory::submitUpdates($contact);

var_dump($contactAfterUpdate);

$name = "Frodo Baggins";
$phoneNumber = "06439111222";
$emailAddress = "[email protected]";
$note = "Note for example";

$newContact = rapidweb\googlecontacts\factories\ContactFactory::create($name, $phoneNumber, $emailAddress, $note);

$customConfig = (object) array(
    'clientID' => '<clientId which you get according to setup above>',
    'clientSecret' => '<clientSecret which you get according to setup above>',
    'redirectUri' => '<your redirect uri>',
    'developerKey' => '<developer key>',
    'refreshToken' => '<refresh token specific for google account>'
);

$contacts = ContactFactory::getAll($customConfig);