ozankurt/google-core

Laravel 5 Google Core

v2.0 2016-11-04 12:15 UTC

This package is auto-updated.

Last update: 2024-09-24 23:41:58 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License

一个包,可以将所有必要的Google设置组合在一起并准备就绪。

安装

步骤 1

ozankurt/google-core 添加到您的composer需求中。

composer require ozankurt/google-core

准备使用

步骤 1

创建一个Google开发者账户,实际上登录到您的任何一个Google账户。

https://developers.google.com/console/

步骤 2

创建一个新的项目。

PS:如果您已经有了项目,请跳过此步骤。

步骤 3

创建一个新的 服务账户 并下载json认证文件。

PS:如果您已经有了项目,请跳过此步骤。

Create Credentials - 1 Create Credentials - 2

步骤 5

将json认证文件复制到PHP中使用的位置。

配置(纯PHP)

示例配置文件

<?php

require 'vendor/autoload.php';

use Kurt\Google\Core;

$googleCore = new Core([
    'applicationName'       => 'Google API Wrapper Demo',
    'jsonFilePath'          => 'Google API Wrapper Demo-174e172143a9.json',
    'scopes' => [
        // 
    ],
]);

配置(Laravel)

步骤 1

将服务提供者添加到您的 config/app.php

'providers' => [
    Kurt\Google\CoreServiceProvider::class,
],

步骤 2

从终端运行 vendor:publish 命令。

php artisan vendor:publish

步骤 3

编辑配置文件中的字段。

<?php

return [

    /*
     * Application Name
     *
     * Name of your project in `https://console.developers.google.com/`.
     */
    'applicationName' => 'Google API Wrapper Demo',

    /*
     * Json Auth File Path
     *
     * After creating a project, go to `APIs & auth` and choose `Credentials` section.
     * 
     * Click `Create new Client ID` and select `Service Account` choose `P12` as the `Key Type`.
     *
     * After downloading the `p12` file copy and paste it in the `storage` directory.
     * 		Example:
     * 			storage/Google API Wrapper Demo-174e172143a9.json
     * 
     */
    'jsonFilePath' => storage_path('Google API Wrapper Demo-174e172143a9.json'),

    /*
     * Here you should pass an array of needed scopes depending on what service you will be using.
     *
     * 		Example:
     * 			For analytics service:
     * 			
     * 				'scopes' => [
     *					'https://www.googleapis.com/auth/analytics.readonly',
     *				],
     */
    'scopes' => [
        //
    ],

];

许可证

本开源软件受MIT许可证许可。