PHP code example of flyhjaelp / gmail2laravel

1. Go to this page and download the library: Download flyhjaelp/gmail2laravel 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/ */

    

flyhjaelp / gmail2laravel example snippets

 php
$credentialsPath = "path/to/credentials/file.json";

$googleClient    =  new gmail2laravel($credentials);

$gmailClient     =  $googleClient->getGmailClient('[email protected]');
 php
$googleClient  =  new gmail2laravel($credentials);

$googleClient()->getGmailClient($email)

$googleClient()->deleteGmailClient($email)

$googleClient()->getEmailsFromAllClients($email)

$googleClient()->availableClients($email)

$googleClient()->enableBatch($email)

$googleClient()->disableBatch($email)
 php
Google_Service_Exception: {
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "forbidden",
    "message": "Delegation denied for [email protected]"
   }
  ],
  "code": 403,
  "message": "Delegation denied for [email protected]"
 }
}
 php
//direct call with direct return from the google client
$googleClient->$gmailClient('[email protected]')->users_labels->listUsersLabels('me');
 php
Google_Service_Exception: {
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "notFound",
    "message": "Not Found"
   }
  ],
  "code": 404,
  "message": "Not Found"
 }
}
 php
Google_Service_Exception: {
 "error": "rate_limit_exceeded"
}