You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Service Account通过Calendar API生成Google Meet链接失败求助

Google Meet链接生成失败问题排查

已创建ServiceAccount并完成域范围委派,基于PHP CodeIgniter 3开发,使用google-api-php版本2。目前可成功创建日历事件,但无法生成Google Meet链接,已为ServiceAccount分配日历权限。无参会者时触发一种错误,添加参会者后出现另一种错误。

Token生成代码

public function generate_token() {
    $jsonKeyFilePath = APPPATH . 'third_party/gentle-meet-399008-352ca7aa0503.json';
    $serviceAccountEmail = 'meet-255@gentle-meet-399008.iam.gserviceaccount.com';
    $scopes = [
        'https://www.googleapis.com/auth/calendar',
        'https://www.googleapis.com/auth/admin.directory.resource.calendar',
        'https://www.googleapis.com/auth/calendar.events',
    ];

    $client = new Google_Client();
    $client->setAuthConfig($jsonKeyFilePath);
    $client->setApplicationName('Google Meet');
    $client->setAccessType('offline');
    $client->setScopes($scopes);
    $client->setSubject($serviceAccountEmail);
    if ($client->isAccessTokenExpired()) {
        $token = $client->fetchAccessTokenWithAssertion();
    } else {
        $token = $client->getAccessToken();
    }
    return $token['access_token'];
}

public function getRandomId() {
    $characters = 'abcdefghijklmnopqrstuvwxyz';
    $randomString = '';
    for ($i = 0; $i < 8; $i++) {
        $index = rand(0, strlen($characters) - 1);
        $randomString .= $characters[$index];
    }
    return $randomString;
}

事件插入代码

$accessToken = $this->generate_token();
$data = array(
    'summary'     => "Testing Meeting",
    'description' => "test",
    'start'       => array(
        'dateTime' => "2023-09-15T20:00:00Z",
        'timeZone' => 'Asia/Kolkata',
    ),
    'end'         => array(
        'dateTime' => "2023-09-15T21:00:00Z",
        'timeZone' => 'Asia/Kolkata',
    ),
    'conferenceData' => array(
        'createRequest' => array(
            'requestId' => uniqid(),
            'conferenceSolutionKey' => array(
                'type' => 'hangoutsMeet',
            ),
        )
    ),
    'attendees' => array(
        array('email' => 'parthkhatri100@gmail.com'),
    ),
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_URL, "https://www.googleapis.com/calendar/v3/calendars/c8ac70eab58d177ca35596a8be3b8ff0a7489462683a6237ca8bf1ff6bd9dc3e@group.calendar.google.com/events?conferenceDataVersion=1");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Content-type: application/json",
    "Accept: application/json",
    "Authorization: Bearer ".$accessToken
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$result = curl_exec($ch);
$errors = curl_error($ch);
$http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return $result;

相关截图说明

  • 无参会者时的错误截图
  • 添加参会者后的错误截图
  • 域范围委派配置截图
  • Service Account配置截图
  • 日历权限配置截图

内容的提问来源于stack exchange,提问作者Khatri Pavan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.10 14:37:03