定制 adnanhussainturki/google-my-business-php 二次开发

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

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

adnanhussainturki/google-my-business-php

Composer 安装命令:

composer require adnanhussainturki/google-my-business-php

包简介

A GOTO PHP Wrapper for GoogleMyBusiness

README 文档

README

Google privately provides its GoogleMyBusiness API to the developers. Being private, the SDK for this API is not available in the Google Services PHP SDK. This projects provides a goto and easy to implement way to use GoogleMyBusiness API.

Requesting Access

Being private API, you need to request access to the same API via the following form for your Google project. You may need to provide your project id and use case.

Credentials

Once your API request got approved, you need to generate credentials i.e client_id and client_secret. With that, you also need to generate refresh token for the following scope

https://www.googleapis.com/auth/business.manage

If you dont know much about how to refresh token, follow the instruction below:

  • While generating credentials in Google Developer Console for your API, enter https://google.myphpnotes.com in authorised javascript field and https://google.myphpnotes.com/callback.php in the redirect_uri filed.
  • Then, go to https://google.myphpnotes.com
  • Provide your client id and client secret in the given field and add scope as following `https://www.googleapis.com/auth/business.manage
  • On submission, you will be requested to authorize access to your Google account. Select the respective account and allow the given scope.
  • On redirection, you will get several important information like access_token and refresh token.
  • Note down the refresh token from that.

Installation

You can install this library to your project via composer using the following command:

composer require adnanhussainturki/google-my-business-php

List Accounts

The GMB works something like this. Your Google Account have many accounts (usually one) and each account contains multiple locations. `

$gmb = new GoogleMyBusiness("APP_KEY", "APP_SECRET");
$gmb->setRefreshToken("_REFRESH_TOKEN_");

$account = new Account();
$account->provideClient($gmb);

$accounts = $account->list();
$firstAccount = $accounts[0];`

List Locations

$gmb = new GoogleMyBusiness("APP_KEY", "APP_SECRET");
$gmb->setRefreshToken("_REFRESH_TOKEN_");

$account = new Account();
$account->provideClient($gmb);

$accounts = $account->list();
$firstAccount = $accounts[0];

$locations = $accounts[0]->locations();
$firstLocation = $locations[0];

List Location Posts

$gmb = new GoogleMyBusiness("APP_KEY", "APP_SECRET");
$gmb->setRefreshToken("_REFRESH_TOKEN_");

$account = new Account();
$account->provideClient($gmb);

$accounts = $account->list();
$firstAccount = $accounts[0];

$locations = $accounts[0]->locations();
$firstLocation = $locations[0];

$posts = $firstLocation->posts();
$firstPost = $posts[0];

List Location Medias

$gmb = new GoogleMyBusiness("APP_KEY", "APP_SECRET");
$gmb->setRefreshToken("_REFRESH_TOKEN_");

$account = new Account();
$account->provideClient($gmb);

$accounts = $account->list();
$firstAccount = $accounts[0];

$locations = $accounts[0]->locations();
$firstLocation = $locations[0];

$posts = $firstLocation->posts();
$firstPost = $posts[0];

$medias = $firstLocation->medias();
$firstMedia = $medias[0];

Create Media

$media = new Media;
$media->provideClient($gmb); // GoogleMyBusiness Client for making credentials available to the media class.
$media->setLocationId($firstLocation->getLocationId()); // Location ID
$media->setCategory("ADDITIONAL");
$media->setFormat('PHOTO');
$media->setSourceUrl("https://cdn.torksky.com/projects/torksky_control/production/products/06019E50K0/ff37c4a25fcf48975831153cc376dfdd.jpeg");
$media->setDescription("Bosch GAS 15");
$media = $media->create();

Create Post

$post = new Post;
$post->provideClient($gmb);
$post->setLocationId($firstLocation->getLocationId());
$post->setCallToAction("ORDER", "https://torksky.com/catalogue/70d1f7b121c397fafc00c6127e7d14c2/view");
$post->setName("Bosch GAS 15");
$post->setDescription("Bosch GAS 15 order now");
$post->setLanguageCode("en");
$post->addMedia($media);
$post->create();

Limitations

By API
  • You cannot add products
  • You cannot add offer in posts
  • You cannot add more than one media in the post
  • There may other limitations also. You may let us know about it.
By Library

This library only concerns for following functions (as of now)

  • List Accounts
  • List Locations
  • List Posts of each location
  • List Medias of each location
  • Create media for a location
  • Create post for a location
  • Feel free to contribute/raise issue.

Buy me a coffee

How to contribute

  • Create a fork, make changes and send a pull request.
  • Raise a issue

License

Licensed under Apache 2.0. You can check its details here.

adnanhussainturki/google-my-business-php 适用场景与选型建议

adnanhussainturki/google-my-business-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 163 次下载、GitHub Stars 达 2, 最近一次更新时间为 2021 年 01 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-01-26