fares/google-meet-api 问题修复 & 功能扩展

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

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

fares/google-meet-api

最新稳定版本:v1.0.0

Composer 安装命令:

composer require fares/google-meet-api

包简介

PHP library to interact with Google Meet API via Google Calendar API

README 文档

README

A simple PHP package to generate Google Meet links via the Google Calendar API.
This package handles OAuth2 authentication, token management, and event creation, returning the Google Meet link automatically.

🚀 Features

  • 🔑 Handles OAuth2 flow (Google login).
  • 💾 Supports access & refresh tokens for long-term use.
  • 📅 Creates Google Calendar events with Meet links.
  • 🔗 Returns the Google Meet link directly.
  • 🛠️ Easily extensible for listing/deleting events or adding attendees.

📦 Installation

Install via Composer:

composer require fares/google-meet-api

⚙️ Setup in Google Cloud

  1. Go to Google Cloud Console.
  2. Create a new project.
  3. Enable the Google Calendar API.
  4. Create OAuth 2.0 Client Credentials (Web Application).
  5. Add your redirect URI (e.g. https://yourapp.com/oauth2callback).
  6. Copy your Client ID and Client Secret.

📂 Package Structure

src/
├── GoogleMeetClient.php   # Initializes Google Client
├── OAuthHandler.php       # Manages login, tokens, refresh
├── MeetGenerator.php      # Creates events and Meet links

🖥️ Usage Example

1️⃣ Initialize Client

use Fares\GoogleMeet\GoogleMeetClient;
use Fares\GoogleMeet\OAuthHandler;

require 'vendor/autoload.php';

$client = new GoogleMeetClient("CLIENT_ID", "CLIENT_SECRET", "https://yourapp.com/oauth2callback");
$oauth = new OAuthHandler($client->getClient());

// Step 1: Redirect user to Google login
echo "<a href='".$oauth->getAuthUrl()."'>Login with Google</a>";

2️⃣ Handle Callback

// oauth2callback.php
use Fares\GoogleMeet\OAuthHandler;
use Fares\GoogleMeet\GoogleMeetClient;

require 'vendor/autoload.php';

$client = new GoogleMeetClient("CLIENT_ID", "CLIENT_SECRET", "https://yourapp.com/oauth2callback");
$oauth = new OAuthHandler($client->getClient());

if (isset($_GET['code'])) {
    $tokens = $oauth->fetchTokens($_GET['code']);
    file_put_contents('token.json', json_encode($tokens)); // Save securely (DB recommended)
    echo "Authentication successful!";
}

3️⃣ Generate a Google Meet Link

use Fares\GoogleMeet\MeetGenerator;

require 'vendor/autoload.php';

$client = new GoogleMeetClient("CLIENT_ID", "CLIENT_SECRET", "https://yourapp.com/oauth2callback");
$oauth = new OAuthHandler($client->getClient());

// Load saved token
$oauth->setAccessToken(json_decode(file_get_contents('token.json'), true));
$oauth->refreshTokenIfNeeded();

// Create meeting
$meet = new MeetGenerator($oauth->getClient());
$link = $meet->createMeeting(
    "Demo Meeting", 
    "2025-09-20T10:00:00-07:00", 
    "2025-09-20T10:30:00-07:00", 
    "America/Los_Angeles"
);

echo "Google Meet Link: " . $link;

⚠️ Notes

  • You must use conferenceDataVersion=1 when inserting events, otherwise no Meet link will be generated.
  • Tokens should be stored securely (preferably in a database, not token.json).
  • Each user must log in once with Google to grant permission.

📌 Future Improvements

  • ✅ Database token manager (MySQL, SQLite, etc.)
  • ✅ Event management (list, update, delete).
  • ✅ Support for adding participants automatically.

📜 License

MIT License. Free to use and modify.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-09-20