All Projects β†’ rapidwebltd β†’ Php Google Contacts V3 Api

rapidwebltd / Php Google Contacts V3 Api

Licence: mit
πŸ‘₯ PHP library for the Google Contacts API (v3)

Projects that are alternatives of or similar to Php Google Contacts V3 Api

Google Places Api
This is a PHP wrapper for Google Places API Web Service. And is Laravel Framework friendly.
Stars: ✭ 147 (+51.55%)
Mutual labels:  google-api, google
Ng Gapi
ng-gapi a Google api module for Angular 6+
Stars: ✭ 126 (+29.9%)
Mutual labels:  google-api, google
Google Api Nodejs Client
Google's officially supported Node.js client library for accessing Google APIs. Support for authorization and authentication with OAuth 2.0, API Keys and JWT (Service Tokens) is included.
Stars: ✭ 9,722 (+9922.68%)
Mutual labels:  google-api, google
Figma To Google Slides
Convert Figma frames into a Google Slides presentation 🍭
Stars: ✭ 385 (+296.91%)
Mutual labels:  google-api, google
React Native Google Sign In
React Native Wrapper for Latest Google Sign-In OAuth SDK / API
Stars: ✭ 213 (+119.59%)
Mutual labels:  google-api, google
Psgsuite
Powershell module for Google / G Suite API calls wrapped in handy functions. Authentication is established using a service account via P12 key to negate the consent popup and allow for greater handsoff automation capabilities
Stars: ✭ 184 (+89.69%)
Mutual labels:  google-api, google
Google Maps React
Companion code to the "How to Write a Google Maps React Component" Tutorial
Stars: ✭ 1,542 (+1489.69%)
Mutual labels:  google-api, google
Gam
command line management for Google Workspace
Stars: ✭ 2,558 (+2537.11%)
Mutual labels:  google-api, google
Raccoon4
APK Downloader for Google Play
Stars: ✭ 369 (+280.41%)
Mutual labels:  google-api, google
Geocoder
🌎 GoLang package that provides an easy way to use the Google Geocoding API
Stars: ✭ 23 (-76.29%)
Mutual labels:  google-api, google
React Places Autocomplete
React component for Google Maps Places Autocomplete
Stars: ✭ 1,265 (+1204.12%)
Mutual labels:  google-api
Google It Automation With Python
Repository to keep track of Google IT Automation with Python provided by Coursera
Stars: ✭ 86 (-11.34%)
Mutual labels:  google
Daily Coding Problem
Series of the problem πŸ’― and solution βœ… asked by Daily Coding problemπŸ‘¨β€πŸŽ“ website.
Stars: ✭ 90 (-7.22%)
Mutual labels:  google
React Google Login
A React Google Login Component
Stars: ✭ 1,317 (+1257.73%)
Mutual labels:  google-api
Google Actions Starter
A Node.js server for Google Assistant (and Google Home).
Stars: ✭ 85 (-12.37%)
Mutual labels:  google
Ot Rtos
OpenThread RTOS, an integration of OpenThread, LwIP, and FreeRTOS.
Stars: ✭ 90 (-7.22%)
Mutual labels:  google
Codejam
Codejam, apac, kickstart, I/O for Women... 2017, 2016, 2015, 2014... All solutions here!
Stars: ✭ 85 (-12.37%)
Mutual labels:  google
Tf Mobilenet V2
Mobilenet V2(Inverted Residual) Implementation & Trained Weights Using Tensorflow
Stars: ✭ 85 (-12.37%)
Mutual labels:  google
Cesium Map
Cesium εœ°ε›Ύζ’δ»ΆοΌŒη”¨δΊŽζ·»εŠ ε›½ε†…ε„ε€§εœ°ε›ΎεŽ‚ε•†ηš„εœ°ε›ΎπŸŒŽ
Stars: ✭ 80 (-17.53%)
Mutual labels:  google
Godotgoogleservice
Google play service, login, achievements, leaderboard.
Stars: ✭ 94 (-3.09%)
Mutual labels:  google

PHP Google Contacts v3 API

Packagist

PHP library for the Google Contacts API (v3)

πŸ’‘ NOTE: If you're starting a new project, we strongly recommend using our PHP Google People API package instead. It is more capable than this package and uses a newer API which will probably be supported for longer.

Installation & Dependencies

This package and its dependencies can be installed using composer.

Just run composer require rapidwebltd/php-google-contacts-v3-api.

Setup

  1. Install required dependencies. See the 'Dependencies' section above.
  2. Copy or rename .config_blank.json to .config.json. Note the dot (.) at the beginning of the file name.
  3. Fill in the clientID, clientSecret and redirectUri in .config.json.
  • Note that redirectUri should be configure to point towards the redirect-handler.php file.
  • The clientID and clientSecret can be found in the Google Developers console at https://console.developers.google.com/ under 'APIs & auth' -> 'Credentials', after enabling the Contacts API.
  1. Go to authorise-application.php in a web browser. This should give you a URL to authorise your application for Google Contacts.
  2. Go to the authorisation URL provided by the previous step.
  3. Accept the permissions requested on the page displayed. You should then be redirected back to the redirect-handler.php file.
  4. The page generated by the redirect-handler.php file should then present you with a refresh token. Copy this into your .config.json.
  5. Setup is done!

Usage

After the library has been installed and the setup and account association steps have been completed, you can make use of the library.

If your framework does not do this for you, remember to include the require the vendor/autoload.php file on any pages you wish to make use of this library on.

Retrieving Google Contacts

The following code will retrieve all contacts from the associated Google account.

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

var_dump($contacts);

The ContactFactory::getAll() method will return an array of Contact objects. The contact's details will be available as public member variables of these objects.

The selfURL contained within each Contact object is the unique reference to this particular contact. If you need to retrieve a specific contact in the future, you will need to store this selfURL.

To retrieve a specific contact (by its selfURL), use the following code.

$selfURL = "...";

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

var_dump($contact);

This ContactFactory::getBySelfURL method will return a single Contact object.

Google Contact properties are accessed as follows.

$selfURL = "...";

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

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

Updating existing Google Contacts

The updating of Google Contacts using this library is done in a very object orientated manner.

You must first retrieve a Contact object using one of the methods mentioned previously. You can then modify the contact object's public member variables. To save these changes back to the Google Contacts service, you then pass the modified object to the ContactFactory::submitUpdates($contact) method.

The following code demonstrates in full retrieving a contact, modifying it and submitting the updates.

$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);

Creating new Google Contacts

Creating a new Google Contact is very easy. Simply call the ContactFactory::create($name, $phoneNumber, $emailAddress) method, passing through appropriate parameters. This method will return the created contact as a Contact object including its newly assigned selfURL.

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

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

Config file override

Each method has optional argument for config file override. It is useful when you want to use work with multiple Google accounts at the same time.

$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);

You have to define all variables as the original config is completely ignored. To be more precise, it doesn't have to exist at all.

Examples

Take a look at the following files for basic examples of how to retrieve contacts. They can also be used to ensure you have currently associated your Google account with the library.

  • test.php
  • test_individual.php
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].