Skip to content

Softlabs/Google

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Google

This package is a simple laravel 4 wrapper for Softlabs/google-api-php-client package.

Usage

// Instantiate google AIP client
$googleAPIClient = new \Google();
// Create Google_CalendarService object
$calendarService = $googleAPIClient->createService("Calendar");

Google::createService($serviceName) method will create a "Google_{$serviceName}Service" object. For example

Google::createService("YouTube") // creates a Google_YouTubeService object

All services can be used as API documentation describes.

Configuration

Sample app/config/google.php file:

return array(
    'client-id'            => '????????????.apps.googleusercontent.com',
    'service-account-name' => '[email protected]',
    'key-file'             => '../app/config/packages/thujohn/analytics/????????????????????????????????????????-privatekey.p12',
    'scope'                => ['https://www.googleapis.com/auth/calendar.readonly', 'https://www.googleapis.com/auth/calendar']
);

You can generate client-id, service-account-name and key-file using Google API Console.

  1. If you have no projects yet, click on 'CREATE PROJECT' button and name your new project. (Project ID field will be filled automatically.)
  • If you already have existing projects, but you want to create a new one, click on the left top dropdown (it will show one of your existing projects) and select Create… from the dropdown menu
  • If you want to use one of your existing projects, just select it from the list
  • Select API Access from the left menu
  • Click on Create an OAuth 2.0 client ID… button and input branding data then click on Next
  • Select Service account radio button, then on Create client ID button
  • Click on Download private key button and save your private key to a safe location
  • Close the popup

Now you can set your config values:

  • client-id: Client ID under the Service account title
  • service-account-name: Email address under the Service account title
  • key-file: the path where you saved your private key in step 7.
  • scope: an array of scopes that you will use in your application. you can find the required scopes for every service in API documentation.

To be able to use google services for a google account you have to share items with the service account (service-account-name). For example if you want to handle google calendars of [email protected], then [email protected] should share its calendars with [email protected].

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages