tombroucke/otomaties-google-reviews-widget 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

tombroucke/otomaties-google-reviews-widget

Composer 安装命令:

composer require tombroucke/otomaties-google-reviews-widget

包简介

Display a Google reviews widget

README 文档

README

A Laravel/Acorn package that displays Google My Business reviews as a beautiful widget. The widget shows the Google logo, star ratings (including half stars), average rating, and total number of reviews.

Features

  • Displays Google Business reviews with logo, stars, rating, and count
  • Supports full and half star ratings
  • Caches review data (default: 24 hours)
  • Daily fetch command for automated updates
  • Fully configurable via .env and config file
  • Responsive design with mobile support

Installation

Install the package via Composer:

composer require otomaties/otomaties-google-reviews-widget

Publish the configuration file:

wp acorn vendor:publish --tag="otomaties-google-reviews-widget-config"

Publish the CSS assets (optional):

wp acorn vendor:publish --tag="otomaties-google-reviews-widget-assets"

Configuration

1. Get Your Google Place ID

Find your business's Place ID:

  1. Go to the Place ID Finder
  2. Search for your business
  3. Copy the Place ID (looks like: ChIJN1t_tDeuEmsRUsoyG83frY4)

2. Create a Google API Key

  1. Go to Google Cloud Console
  2. Create a new project or select an existing one
  3. Go to APIs & Services > Library
  4. Search for and enable "Places API"
  5. Go to APIs & Services > Credentials
  6. Click Create Credentials > API Key
  7. Copy the API key
  8. (Recommended) Click Restrict Key and limit it to "Places API" only

3. Configuration

Add your Place ID to the config file:

Edit config/otomaties-google-reviews-widget.php (publish it first if needed):

'place_id' => 'ChIJN1t_tDeuEmsRUsoyG83frY4',

Add your API key to .env:

# Your Google API Server Key (from step 2)
GOOGLE_API_SERVER_KEY=AIzaSyD1234567890abcdefghijklmnopqrstuv

# Optional: Cache duration in seconds (default: 86400 = 24 hours)
GOOGLE_REVIEWS_CACHE_DURATION=86400

3. Configuration File

The config file (config/otomaties-google-reviews-widget.php) allows you to customize display settings:

'display' => [
    'show_logo' => true,   // Show Google logo
    'show_stars' => true,  // Show star ratings
    'show_rating' => true, // Show average rating number
    'show_count' => true,  // Show review count
],

Usage

Display the Widget

Using Shortcode:

[google_reviews_widget]

Using Blade:

@include('GoogleReviewsWidget::widget')

Don't forget to include the CSS file in your theme:

<link
  rel="stylesheet"
  href="{{ asset('vendor/otomaties-google-reviews-widget/google-reviews-widget.css') }}"
/>

Fetch Reviews

Manually fetch the latest reviews:

wp acorn google-reviews:fetch

Schedule Daily Updates

Add to your app/Console/Kernel.php:

protected function schedule(Schedule $schedule)
{
    $schedule->command('google-reviews:fetch')->daily();
}

Or set up a cron job:

0 2 * * * cd /path/to/your/site && wp acorn google-reviews:fetch

Programmatic Usage

You can also use the service directly in your code:

use Otomaties\GoogleReviewsWidget\Services\GoogleReviewsService;

$service = new GoogleReviewsService();

// Get cached reviews
$reviews = $service->getReviews();

// Fetch fresh reviews
$reviews = $service->fetchReviews();

// Get star rating breakdown
$stars = $service->getStarRating(4.5);
// Returns: ['full' => 4, 'half' => 1, 'empty' => 0]

Community

Keep track of development and community news.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固