a Google API v3 wrapper for Laravel 4.x

Overview

A Google API v3 wrapper for Laravel 4

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

Installation

Add the required package to your composer.json file

{
    "require": {
    	...
		"pongocms/googleapi": "1.0"
	}
}

Set minimum-stability to 'dev'

In order to avoid Composer's possible conflicts, just set your composer.json 'minimum-stability' to 'dev'

{
	...
    "minimum-stability": "dev"
}

...then just run composer update

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:

// 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.

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:

php artisan config:publish pongocms/googleapi

...and put them to the oauth2 parameters into the config file

// 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.

Using the GoogleAPI facade

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

Need to use the Google Calendar service?

// routes.php

Route::get('/', function()
{
   if ( Input::has('code') )
   {
   	$code = Input::get('code');
   	
   	// 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!');
});

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

Route::get('/protected', function()
{
   // Get the google service (related scope must be set)
   $service = GoogleAPI::getService('Calendar');
   
   // invoke API call
   $calendarList = $service->calendarList->listCalendarList();

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

   return link_to('/logout', 'Logout');
});
You might also like...
A simple API wrapper to Gigapay's APIs for Laravel Framework
A simple API wrapper to Gigapay's APIs for Laravel Framework

Laravel-Gigapay A simple API wrapper for Gigapay's APIs. It gives you helper methods that will make your work with gigapay's API easy, fast and effici

Lavacharts is a graphing / charting library for PHP 5.4+ that wraps Google's Javascript Chart API.

Lavacharts 3.1.12 Lavacharts is a graphing / chart library for PHP5.4+ that wraps the Google Chart API. Stable: Dev: Developer Note Please don't be di

Adds phone number functionality to TYPO3 based on the PHP port of Google's libphonenumber API by giggsey

TYPO3 Phone Adds phone number functionality to TYPO3 based on the PHP port of Google's libphonenumber API by giggsey. Installation composer require si

Laravel-tagmanager - An easier way to add Google Tag Manager to your Laravel application.

Laravel TagManager An easier way to add Google Tag Manager to your Laravel application. Including recommended GTM events support. Requirements Laravel

 Manage self-hosted Google Fonts in Laravel apps
Manage self-hosted Google Fonts in Laravel apps

This package makes self-hosting Google Fonts as frictionless as possible for Laravel users. To load fonts in your application, register a Google Fonts embed URL and load it with the @googlefonts Blade directive.

Automatically disable Google's FLoC in Laravel apps
Automatically disable Google's FLoC in Laravel apps

Automatically disable Google's FLoC in Laravel apps This package will automatically disable Google's FLoC. Support us We invest a lot of resources int

Google Cloud Storage filesystem driver for Laravel
Google Cloud Storage filesystem driver for Laravel

Google Cloud Storage filesystem driver for Laravel Google Cloud Storage filesystem driver for Laravel. This started as a fork from Superbalist/laravel

Laravel real-time CRUD using Google Firebase.
Laravel real-time CRUD using Google Firebase.

Laravel real-time CRUD using Google Firebase.

Laravel Google Maps Package

Laravel Google Maps This repo aims to use google map features in laravel 5.x. It is easy to use and flexible, you can just install this package and en

Owner
null
A Laravel Wrapper for the CoinDCX API. Now easily connect and consume the CoinDCX Public API in your Laravel apps without any hassle.

This package provides a Laravel Wrapper for the CoinDCX API and allows you to easily communicate with it. Important Note This package is in early deve

Moinuddin S. Khaja 2 Feb 16, 2022
Mollie API client wrapper for Laravel & Mollie Connect provider for Laravel Socialite

Mollie for Laravel Laravel-Mollie incorporates the Mollie API and Mollie Connect into your Laravel or Lumen project. Accepting iDEAL, Apple Pay, Banco

Mollie 289 Nov 24, 2022
Collection of Google Maps API Web Services for Laravel

Collection of Google Maps API Web Services for Laravel Provides convenient way of setting up and making requests to Maps API from Laravel application.

Alexander Pechkarev 467 Jan 5, 2023
Adds phone number functionality to Laravel based on the PHP port of Google's libphonenumber API by giggsey.

Laravel Phone Adds phone number functionality to Laravel based on the PHP port of Google's libphonenumber API by giggsey. Table of Contents Demo Insta

null 2.1k Jan 2, 2023
Laravel wrapper package for the Aimon.it API

Laravel Aimon Package A laravel wrapper package for the Aimon.it API. For more information see Aimon Requirements Laravel 6 or later Installation Inst

Ruslan 3 Aug 7, 2022
Laravel API wrapper to interact fluently with your Janus Media Server

Laravel API wrapper to interact fluently with your Janus Media Server. Core server interactions, as well as the video room plugin included.

Richard  Tippin 11 Aug 21, 2022
Open Food Facts API wrapper for Laravel

Laravel Open Food Facts API This package provides a convenient wrapper to the Open Food Facts API for Laravel applications (5.7+). Installation You ca

Open Food Facts 112 Jan 4, 2023
Laravel wrapper for Sentry Official API

Laravel Sentry API Provides a simple laravel wrapper to some of the endpoints listed on (Official Sentry API)[https://docs.sentry.io/api/]. **Note: Th

Pedro Santiago 1 Nov 1, 2021
Laravel wrapper for the Gmail API

Laravel Gmail Gmail Gmail API for Laravel 8 You need to create an application in the Google Console. Guidance here. if you need Laravel 5 compatibilit

Daniel Castro 244 Jan 3, 2023
Simple and ready to use API response wrapper for Laravel.

Laravel API Response Simple Laravel API response wrapper. Installation Install the package through composer: $ composer require obiefy/api-response Re

Obay Hamed 155 Dec 14, 2022