PHP code example of joomla / google

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

    

joomla / google example snippets


use Joomla\Google\Google;

$google = new Google;

use Joomla\Google\Google;
use Joomla\Registry\Registry;

$options = new Registry;
$options->set('clientid', 'google_client_id.apps.googleusercontent.com');
$options->set('clientsecret', 'google_client_secret');

$google = new Google($options);

$calendar = $google->data('calendar');

$analytics = $google->data('analytics');

use Joomla\Google\Google;
use Joomla\Registry\Registry;

$options = new Registry;

// Client ID and Client Secret can be obtained  through the Google API Console (https://code.google.com/apis/console/).
$options->set('clientid', 'google_client_id.apps.googleusercontent.com');
$options->set('clientsecret', 'google_client_secret');
$options->set('redirecturi', JURI::current());

$google = new Google($options);

// Get a calendar API object
$calendar = $google->data('calendar');

// If the client hasn't been authenticated via OAuth yet, redirect to the appropriate URL and terminate the program
if (!$calendar->isAuth())
{
	JResponse::sendHeaders();
	die();
}

// Create a new Google Calendar called "Hello World."
$calendar->createCalendar('Hello World');