承接 scottybo/laravel-google-my-business 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

scottybo/laravel-google-my-business

Composer 安装命令:

composer require scottybo/laravel-google-my-business

包简介

A package for Laravel which implements the Google My Business API

README 文档

README

Note: To use the Google My Business API you have to apply for access: https://docs.google.com/forms/d/1XTQc-QEjsE7YrgstyJxbFDnwmhUhBFFvpNJBw3VzuuE/viewform

This is a Laravel ready implementation of the Google My Business PHP Library (v4.4) as provided by Google on https://developers.google.com/my-business/samples/

Please refer to https://developers.google.com/my-business/reference/rest/ for information on how the Google My Business API functions - more useful links are available at the bottom of this document.

Debugging

I'm putting this above everything else as it's extremely important. The Google My Business Client library doesn't support detailed error responses: https://developers.google.com/my-business/content/support#detailed_error_responses

So when something goes wrong, you get an extremely unhelpful 400 error message such as Request contains an invalid argument.

To get more detailed error messages we need to add the HTTP header: X-GOOG-API-FORMAT-VERSION: 2 to the request and the error message that gets returned will be a lot more useful.

There isn't a pretty way to do this, but all you need to do is open:

/vendor/google/apiclient/src/Google/Http/REST.php

And in the doExecute function modify as follows

      $httpHandler = HttpHandlerFactory::build($client);
      
      // Add the header to the request
      $request = $request->withHeader('X-GOOG-API-FORMAT-VERSION', '2');

Once you've finished debugging, remove this added line.

Installation

Run composer require scottybo/laravel-google-my-business

Or to install via composer - edit your composer.json to require the package.

"require": { "scottbo/laravel-google-my-business": "1.*" }

Then run composer update in your terminal to pull it in.

Laravel

Important: It's highly recommend you use https://github.com/pulkitjalan/google-apiclient to handle the Google Client setup. The code examples further down this document assume you're using this library.

To use this Google My Business package in a Laravel project add the following to the providers array in your config/app.php

Scottybo\LaravelGoogleMyBusiness\GoogleMyBusinessServiceProvider::class,

Next add the following to the aliases array in your config/app.php

'GoogleMyBusiness' => Scottybo\LaravelGoogleMyBusiness\GoogleMyBusiness::class

Google My Business Discovery document

The Google My Business API discovery document is a JSON document that describes the surface for a particular version of the API. You use the discovery document in conjunction with the Google API Discovery Service.

mybusiness_google_rest_v4p4.json has been included with this project for your reference (downloaded from: https://developers.google.com/my-business/samples/)

Tips

Code example

(Work in progress)

use Google; // See: https://github.com/pulkitjalan/google-apiclient
use GoogleMyBusiness;


class MyExampleClass
{

    function authRedirect() {

        // Define the GMB scope
        $scopes = [
            'https://www.googleapis.com/auth/plus.business.manage'
        ];

        // Define any configs that overrride the /config/google.php defaults from pulkitjalan/google-apiclient
        $googleConfig = array_merge(config('google'),[
            'scopes' => $scopes,
            'redirect_uri' => config('app.callback_url').'/callback/google/mybusiness'
        ]);

        // Generate an auth request URL
        $googleClient = new Google($googleConfig);
        $loginUrl = $googleClient->createAuthUrl();
        
        // Send user to Google for Authorisation
        return redirect()->away($loginUrl);
    }
    
    function getAccountName(Google $googleClient) {
        $gmb = new GoogleMyBusiness($googleClient);
        return $gmb->getAccountName();
    }

}

Useful links

Mostly for my reference as I develop this package, but you might find them useful too!

scottybo/laravel-google-my-business 适用场景与选型建议

scottybo/laravel-google-my-business 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 60.74k 次下载、GitHub Stars 达 33, 最近一次更新时间为 2018 年 05 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「google」 「laravel」 「laravel5」 「google my business」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 scottybo/laravel-google-my-business 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 scottybo/laravel-google-my-business 我们能提供哪些服务?
定制开发 / 二次开发

基于 scottybo/laravel-google-my-business 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 33
  • Watchers: 2
  • Forks: 22
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2018-05-06