定制 eng-mahmoud-elgml/google-integration 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

eng-mahmoud-elgml/google-integration

最新稳定版本:1.2.4

Composer 安装命令:

composer require eng-mahmoud-elgml/google-integration

包简介

This Package To Make Integration With Google Drive And Google sheets Very Simple

README 文档

README

Overview

This is a laravel laravel-package to help in google integration with two main services.

  • Google Drive
  • Google Sheets

Installation

install it with CL:
composer require eng-mahmoud-elgml/google-integration
run php artisan vendor:publish --provider="EngMahmoudElgml\GoogleIntegration\Providers\GoogleServiceProvide" --tag="config"

by default the package is handle google callback and return access token, but you can override on it and use your own route and callback function and all you need in callback function is create object from GoogleConnection Class and use handleCallback() method and pass $request['code'] to it which will return access token

Now Create Your Google Project in google developers console and get the Oauth2-credentials and download it as a json file get the values from the file and set it in google config file or .env file.

Also, You Will find in config/google.php an array called token you will get it after log in with Google Account , to get google login link:
you can create an object from GoogleConnection Class and use getAuthUrl methode to get the link

after login if the package handled google-callback itself: you will get the access token directly after login, copy its values and paste it inside token array in config/google.php

Also, if you want to save the token in database you can pass your token manually when create any GoogleFile or SpreadSheet object as second parameter in constructor Now You Ready to Use The Package Features

Usage

1- Google Drive Features

To use drive features you must create object from GoogleFile class and pass google file id in constructor then you can:
a- copy it
with $googleFileObject->copy() you can copy the file and if you want the copied one with specific name you can pass the name in first parameter, otherwise the name will be a random number.
and if you want it in specific folder you can pass the folder id in second parameter.
b- export it
with $googleFileObject->export() you can export the file content with default mime type application/pdf and if you want to change it you can pass mime type in first parameter. but first take a look at: Supported mime types from Google
And if you want to save it directly to your local disk you can pass the second parameter as your path and third one as file name.
c- delete it
with $googleFileObject->delete() you can delete the file.
d- share it
with $googleFileObject->share($email,$role) you can share the file with specific email and you can pass the role in second parameter as reader or writer or owner.

2- Google Sheets Features

To use Google Sheets features you must create object from SpreadSheet class and pass spreadsheet id in constructor then you can:
a- List sheets in spreadsheet file
with $spreadSheetObject->list() you can get all sheets in spreadsheet file.
b- Get sheet data (Read the sheet)
with $spreadSheetObject->read($sheetName) you can get all data in specific sheet in spreadsheet file. and you can get specific range of data by passing the range in second parameter.
Ex:

$spreadSheetObject->read('Sheet1','A1:B2');

c- Update Cell Values
with $spreadSheetObject->updateCells($sheetName,$cellesWithItsValues) you can update cell values in specific sheet in spreadsheet file.
Ex:

$spreadSheetObject->updateCells('Sheet1',[
    'A1'=>'value1',
    'B1'=>'value2',
    'A2'=>'value3',
    'B2'=>'value4',
]);

d- Bulk Update To The Sheet
if you want to update all the cells in the sheet you can use $spreadSheetObject->override($sheetName,$data) and pass the sheet name in first parameter and the data in second parameter as array of arrays. each array in the main array is a row in the sheet and each array inside it is a cell in the row. Ex:

$spreadSheetObject->override('Sheet1',[
    ['value1','value2'],
    ['value3','value4'],
]);

统计信息

  • 总下载量: 5
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2023-10-15