我正在尝试使用Google APIs Client Library for PHP创建一个新的日历事件并附加一个hangoutsMeet
会议。尝试这样做时,我收到一条错误消息,指出Invalid conference type value
。
使用相同的代码,我可以创建一个新事件并附加一个eventHangout
会议。
我了解为什么会收到该错误:根据API,我的日历仅支持eventHangout
会议类型。
<<<< 2020年4月3日的编辑#1
根据Andres Duarte的回答进行澄清:仅当我尝试通过API创建事件时,这才作为限制。当我使用Google日历界面手动创建活动时,我 am 可以添加Google Meet。实际上,这是下拉菜单中显示的唯一会议选项。
>>>>
我的问题是,如何更新我的日历设置(使用或不使用API),以便可以使用API创建具有附加的hangoutsMeet
个会议的活动?
以下是一些示例代码来演示我尝试过的操作:
<<<< 2020年4月3日的修改#2
根据hooman182的回答进行澄清:我已更新代码示例,以证明我使用字符串正确设置了requestId
。
>>>>
try {
// fetch the calendar
$calendar = 'myCalendar';
$calendarObject = $service->calendars->get($calendar);
echo "<pre>";
echo "\nORIGINAL *******************************************************\n\n";
var_dump($calendarObject->getConferenceProperties()->getAllowedConferenceSolutionTypes());
// set the allowed conferences solutions type
$calendarObject->getConferenceProperties()->setAllowedConferenceSolutionTypes(
array(
"hangoutsMeet",
"eventHangout",
"eventNamedHangout",
)
);
echo "\nUPDATED *******************************************************\n\n";
var_dump($calendarObject->getConferenceProperties()->getAllowedConferenceSolutionTypes());
// save the changes to the calendar
$calendarObject = $service->calendars->patch($calendar, $calendarObject);;
echo "\nSAVED *********************************************************\n\n";
var_dump($calendarObject->getConferenceProperties()->getAllowedConferenceSolutionTypes());
// add a createRequest to my event
$event->setConferenceData(new Google_Service_Calendar_ConferenceData(array(
'createRequest' => array(
'requestId' => md5(time()),
'conferenceSolutionKey' => array(
'type' => 'hangoutsMeet',
)
)
)));
// save the event
$event = $service->events->insert($calendar, $event, array(
'conferenceDataVersion' => 1
));
} catch (Google_Service_Exception $e) {
echo "\nERRORS ********************************************************\n\n";
var_dump($e->getErrors());
die;
}
这是上面的输出:
ORIGINAL *******************************************************
array(1) {
[0]=>
string(12) "eventHangout"
}
UPDATED *******************************************************
array(3) {
[0]=>
string(12) "hangoutsMeet"
[1]=>
string(12) "eventHangout"
[2]=>
string(17) "eventNamedHangout"
}
SAVED *********************************************************
array(1) {
[0]=>
string(12) "eventHangout"
}
ERRORS ********************************************************
array(1) {
[0]=>
array(3) {
["domain"]=>
string(6) "global"
["reason"]=>
string(7) "invalid"
["message"]=>
string(30) "Invalid conference type value."
}
}
其他详细信息:
答案 0 :(得分:1)
在创建活动之前,您需要使用服务帐户凭据来模拟G Suite域中的用户,这样,您就可以创建hangoutsMeet
会议类型的活动,该会议类型仅适用于G套件用户。
即使您的服务帐户具有域范围的委派,它也不会像documentation那样具有与G Suite用户相同的特权:
与用户不同,服务帐户不是您的G Suite域的成员 帐户。
在您的情况下,这就是为什么您只能使用eventHangout
会议类型创建事件的原因,该会议类型是针对event资源的文档中所述的供消费者使用的:
可能的值为:
针对消费者(http://hangouts.google.com)的环聊的“ eventHangout”
“ eventNamedHangout”,适用于G Suite用户(http://hangouts.google.com)的经典环聊
“视频群聊聚会”(http://meet.google.com)
3P会议提供商的“ addOn”
答案 1 :(得分:1)
您显然忘记了在请求中添加requestID。
资源:Add video and phone conferences to events
"conferenceData": {
"createRequest": {
"conferenceSolutionKey": {
"type": "eventHangout"
},
"requestId": "yourcodehere"
}
}
您可以通过为 createRequest 提供一个新生成的 requestId (可以是随机的字符串)为事件创建新的会议。会议是异步创建的,但是您始终可以检查请求的状态,以使您的用户知道发生了什么。
我希望有帮助。