我无法通过以下代码从GSUIT服务帐户为谷歌日历api生成meet链接。当我运行这个功能时,我得到了这个错误
错误:
致命错误:未捕获的Google\Service\异常:{quot;错误":{;错误";:[{quotquot;域"全局","原因":"无效","消息":"会议类型值无效;代码":400;消息":"无效的会议类型值&{}}在D:\xamplep\htdocs\projects\serviceaccount\vendor\google\apiclient\src\Http\REST.php中:128堆栈跟踪:#0 D:\xampp\htdocs\projects\servicesaccount\vendor \google\aipclient\src\Wttp\REST.php(103(:google\Http\REST:解码HttpResponse(Object(GuzzleHttp\Psr7\Response(,Object(GuffleHttp\Psr7\Request(,'google\Service\…'(#1[内部函数]:Google\Http\REST::doExecute(Object(GuzzleHttp\Client(,Object(GuffleHttp\Psr7\Request(,'Google\Service\…'(#2 D:\xamplep\htdocs\projects\serviceaccount\vendor\google\apiclient\src\Task\Runner.php(182(:call_user_func_array(array,array(#3 D:\xamp\htdocs \projects\serviceaccount\ vendor\google \apiclient \src\Http\REST.php(66(:google\Task\Runer->run((#4 D:\xamplep\htdocs\projects\serviceaccount\vendor\google\apiclient \src\Client.php,位于D:\xampp\htdocs\projects\servicesaccount\vendor \google\aipclient \src\Http\REST.php,第128行
代码:
<pre>
$client = new GoogleClient();
$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 GoogleServiceCalendar($client);
$event = new GoogleServiceCalendarEvent(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-clientcomposer需要google/apiclient:^2.10
如果您要查看Google Calendar API PHP参考文档,则Google_Service_Calendar_Events_Resource插入((需要一个Google_Services_Calendar_Event对象。其中conferenceData
应为Google_Service_Calendar_ConferenceData。
示例代码:
$conference = new Google_Service_Calendar_ConferenceData();
$conferenceRequest = new Google_Service_Calendar_CreateConferenceRequest();
$conferenceSolutionKey = new Google_Service_Calendar_ConferenceSolutionKey();
$conferenceSolutionKey->setType("hangoutsMeet");
$conferenceRequest->setRequestId('ADGGSH'. time());
$conferenceRequest->setConferenceSolutionKey($conferenceSolutionKey);
$conference->setCreateRequest($conferenceRequest);
$event->setConferenceData($conference);
或
$event = new GoogleServiceCalendarEvent(array(
......
'conferenceData' => $conference
));
$client = new GoogleClient();
$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('clientemail@gserviceaccount.com'); //This is my GSUIT service account(client email) created which is impersonating(linked to my personal GSUIT email)
$client->setAccessType('offline');
$cal_id = 'mypersonalemail@gsuit.com'; //The events created will appear on my GSUIT personal account
$calendarService = new GoogleServiceCalendar($client);
$conference = new GoogleServiceCalendarConferenceData();
$conferenceRequest = new GoogleServiceCalendarCreateConferenceRequest();
$conferenceSolutionKey = new GoogleServiceCalendarConferenceSolutionKey();
$conferenceSolutionKey->setType("hangoutsMeet");
$conferenceRequest->setRequestId('ADGGSH'. time());
$conferenceRequest->setConferenceSolutionKey($conferenceSolutionKey);
$conference->setCreateRequest($conferenceRequest);
$event = new GoogleServiceCalendarEvent(array(
......
'conferenceData' => $conference
));
$createdEvent = $calendarService->events->insert($cal_id, $event, array('conferenceDataVersion' => 1));
错误:
致命错误:未捕获的Google\Service\异常:{quot;错误":{;错误";:[{quot:域"全局"代码":400;消息":"无效的会议类型值&{}}