【发布时间】:2021-09-25 14:25:54
【问题描述】:
我无法通过以下代码从 GSUIT 服务帐户为 google 日历 api 生成会议链接。运行此功能时出现此错误
错误:
致命错误:未捕获的 Google\Service\Exception: { "error": { "errors": [ { "domain": "global", "reason": "invalid", "message": "无效的会议类型值。” } ], "code": 400, "message": "无效的会议类型值。" } } 在 D:\xampp\htdocs\projects\serviceaccount\vendor\google\apiclient\src\Http\REST.php:128 堆栈跟踪:#0 D:\xampp\htdocs\projects\serviceaccount\vendor\google\apiclient \src\Http\REST.php(103): Google\Http\REST::decodeHttpResponse(Object(GuzzleHttp\Psr7\Response), Object(GuzzleHttp\Psr7\Request), 'Google\Service\...') # 1 [内部函数]: Google\Http\REST::doExecute(Object(GuzzleHttp\Client), Object(GuzzleHttp\Psr7\Request), 'Google\Service\...') #2 D:\xampp\htdocs\ projects\serviceaccount\vendor\google\apiclient\src\Task\Runner.php(182): call_user_func_array(Array, Array) #3 D:\xampp\htdocs\projects\serviceaccount\vendor\google\apiclient\src\Http\ REST.php(66): Google\Task\Runner->run() #4 D:\xampp\htdocs\projects\serviceaccount\vendor\google\apiclient\src\Client.php 在 D:\xampp\htdocs\projects \serviceaccount\vendor\google\apiclient\src\Http\REST.php 在第 128 行
代码:
<pre>
$client = new Google\Client();
$client->setAuthConfig($jsonKey);
$client->setScopes(['https://www.googleapis.com/auth/calendar', 'https://www.googleapis.com/auth/calendar.events','https://www.googleapis.com/auth/admin.reports.audit.readonly']);
$client->setSubject('myserviceemail@gserviceaccount.com');
$client->setAccessType('offline');
$cal_id = 'myemail@gsuit.com';
$calendarService = new Google\Service\Calendar($client);
$event = new Google\Service\Calendar\Event(array(
'summary' => 'test link generate', //'Google Calendar ',
'description' => 'Book Room', //'Book Room',
'start' => array(
'dateTime' => '2021-07-17T00:50:00+05:30',//'2018-08-16T14:30:00-00:00',
'timeZone' => 'Asia/Kolkata',
),
'end' => array(
'dateTime' => '2021-07-17T00:55:00+05:30',//'2018-08-16T14:30:00-01:00',
'timeZone' => 'Asia/Kolkata',
),
'reminders' => array(
'useDefault' => FALSE,
'overrides' => array(
array('method' => 'popup', 'minutes' => 10),
),
),
'conferenceData' => array(
'createRequest' => array(
'conferenceSolutionKey' => array(
'type' => 'hangoutsMeet'
),
'requestId' => 'ADGGSH'. time()
)
)
));
$createdEvent = $calendarService->events->insert($cal_id, $event, array('conferenceDataVersion' => 1));
</pre>
此代码出现以下错误,但不添加(ConferenceData 属性并设置 ConferenceDataVersion = 1)我可以在没有环聊链接的情况下创建活动
资源:
https://github.com/googleapis/google-api-php-client 作曲家需要 google/apiclient:^2.10
【问题讨论】: