定制 ostapovich/google-reviews 二次开发

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

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

ostapovich/google-reviews

Composer 安装命令:

composer require ostapovich/google-reviews

包简介

A library for fetching Google reviews

README 文档

README

This library fetches Google reviews for a specific place using PHP.

Installation

Install via Composer:

composer require ostapovich/google-reviews

Usage

For this packege your needs 2 urls. You can take them according to the following instructions, it is much easier than Google Business

Step 1

Step 2

Step 3

Here's a basic example:

<?php

require 'vendor/autoload.php';

use Ostapovich\GoogleReview;

// Initialize the GoogleReview class
$googleReview = new GoogleReview();

// URL of the Google reviews page
$firstUrl = 'https://www.google.com/async/reviewDialog?ei=owqIZv3iLveJxc8PoPCzuAI&opi=89978449&yv=3&cs=1&async=feature_id:0x47e66e2964e34e2d%3A0x8ddca9ee380ef7e0,review_source:All%20reviews,sort_by:qualityScore,is_owner:false,filter_text:,associated_topic:,next_page_token:,async_id_prefix:,_pms:s,_fmt:pc'; // Your First URL here, i add paris
$secondUrl = 'https://www.google.com/async/reviewSort?vet=12ahUKEwj9mbuqlZCHAxWlRvEDHTCpD10Qxyx6BAgBEBU..i&ved=2ahUKEwj9mbuqlZCHAxWlRvEDHTCpD10Qjit6BQgBEKsE&bl=UndH&s=web&opi=89978449&yv=3&cs=1&async=feature_id:0x47e66e2964e34e2d%3A0x8ddca9ee380ef7e0,review_source:All%20reviews,sort_by:newestFirst,is_owner:false,filter_text:,associated_topic:,next_page_token:,_pms:s,_fmt:pc'; // Your Second URL here here, i add paris

try {
    // Fetch all reviews
    $reviews = $googleReview->getReviewsAll($secondUrl, 3); // if you need all reviews do not specify the second parameter

    // Output reviews
    foreach ($reviews as $review) {
        echo "Name: " . $review['name'] . "\n";
        echo "Rating: " . $review['rating'] . "\n";
        echo "Review: " . $review['text'] . "\n\n";
    }
} catch (Exception $e) {
    echo 'Error: ' . $e->getMessage();
}

// Get general location, rating, and count
$this->getRating($this->getCrawlerObj($firstUrl));
$this->getReviewsCount($this->getCrawlerObj($firstUrl));

Methods

  • getReviewsAll(string $url,int $page = 0): array|\Exception

    • Fetches all reviews from the provided URL.
  • getCrawlerObj(string $url): Crawler|\Exception

    • Creates a Crawler object for the provided URL.
  • getNextReviewsPage(string $nextPageUrl, int $page = 0): string|\Exception

    • Fetches the HTML content of the next page of reviews.
  • getNextPageToken(Crawler $crawler): string|null|\Exception

    • Extracts the data-next-page-token from the HTML content.
  • getRating(Crawler $crawler)

    • Extracts the overall rating from the HTML content.
  • getReviews(Crawler $crawler): array|\Exception

    • Extracts the reviews from the HTML content.
  • getReviewsIds(Crawler $crawler): array|\Exception

    • Extracts the review IDs from the HTML content.
  • getReviewsCount(Crawler $crawler): int|null|\Exception

    • Extracts the total number of reviews from the HTML content.
  • getReviewsTexts(Crawler $crawler): array|\Exception

    • Extracts the review texts from the HTML content.
  • getReviewsReply(Crawler $crawler): array|\Exception

    • Extracts the review replies from the HTML content.
  • getReviewsNames(Crawler $crawler): array|\Exception

    • Extracts the reviewer names from the HTML content.
  • getReviewsRatings(Crawler $crawler): array|\Exception

    • Extracts the review ratings from the HTML content.
  • getProfilesImg(Crawler $crawler): array

    • Extracts the profile Img's from the HTML content.

ostapovich/google-reviews 适用场景与选型建议

ostapovich/google-reviews 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 07 月 05 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 ostapovich/google-reviews 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-07-05