2017 © Pedro Peláez
 

library googleapi

A Google API v3 wrapper for Laravel 4.x with multiple Google Client IDs support

image

baffo/googleapi

A Google API v3 wrapper for Laravel 4.x with multiple Google Client IDs support

  • Monday, June 30, 2014
  • by baffo
  • Repository
  • 1 Watchers
  • 1 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

This Package has been forked to allow it to work with illuminate 4.2.* and to add support for multiple Google Client IDs, to seemlessly enable us to switch between multiple working environments, (*1)

Requires an additional config variable to be specified in your /app/config/app.php file:, (*2)


// app/config/app.php '...', 'environment' => 'local', // local, prod, ...

A Google API v3 wrapper for Laravel 4

This package enables a Laravel flavoured way to manage Google services through its API interface (v3), (*3)

Installation

Add the required package to your composer.json file, (*4)

{
    "require": {
        ...
            "google/apiclient": "dev-master",
        "pongocms/googleapi": "dev-master"
    }
}

...then just run composer update, (*5)

Laravel implementation

This package includes a ServiceProvider that will give access to a helpful GoogleAPI facade. Set the GoogleapiServiceProvider reference in your /app/config/app.php like this:, (*6)


// app/config/app.php 'providers' => array( '...', 'Pongo\GoogleAPI\GoogleapiServiceProvider' );

Export and edit the configuration file

Before using this package, you will need to activate a profile from Google developer and get your personal code from the Google Developers Console in order to obtain access and use their services through API calls., (*7)

Once obtained Client ID and Client Secret strings for web application from the Google Developers Console and set a valid Redirect URI callback, export the package config file:, (*8)

php artisan config:publish pongocms/googleapi, (*9)

...and put them to the oauth2 parameters into the config file, (*10)


// app/config/packages/pongocms/googleapi/config.php return array( // OAuth2 Setting, you can get these keys in Google Developers Console 'oauth2_client_id' => '< YOUR CLIENT ID >', 'oauth2_client_secret' => '< YOUR CLIENT SECRET >', 'oauth2_redirect_uri' => 'http://localhost:8000/', // Change it according to your needs ... );

Set also the correct scope for the services you will use in your application (and remember to activate related APIs inside the Google Developers Console => APIS & AUTH => APIs). Refer to Google API wiki for any help., (*11)

Using the GoogleAPI facade

Once everything set correctly, you'll gain access to the GoogleAPI facade in a pure Laravel style., (*12)

Need to use the Google Calendar service?

```php, (*13)

// routes.php, (*14)

Route::get('/', function() { if ( Input::has('code') ) { $code = Input::get('code');, (*15)

    // authenticate with Google API
    if ( GoogleAPI::authenticate($code) )
    {
        return Redirect::to('/protected');
    }
}

// get auth url
$url = GoogleAPI::authUrl();

return link_to($url, 'Login with Google!');

});, (*16)

Route::get('/logout', function() { // perform a logout with redirect return GoogleAPI::logout('/'); });, (*17)

Route::get('/protected', function() { // Get the google service (related scope must be set) $service = GoogleAPI::getService('Calendar');, (*18)

// invoke API call
$calendarList = $service->calendarList->listCalendarList();

foreach ( $calendarList as $calendar )
{
    echo "{$calendar->summary} <br>";
}

return link_to('/logout', 'Logout');

});, (*19)

```, (*20)

The Versions

30/06 2014

dev-master

9999999-dev https://github.com/baffo/googleapi-laravel

A Google API v3 wrapper for Laravel 4.x with multiple Google Client IDs support

  Sources   Download

MIT

The Requires

 

laravel api v3 google laravel4 googleapi

30/06 2014

1.0

1.0.0.0 https://github.com/PongoCMS/googleapi-laravel

a Google API v3 wrapper for Laravel 4.x

  Sources   Download

MIT

The Requires

 

laravel api v3 google laravel4 googleapi