Mo *_*o I 5 php google-calendar-api google-api-php-client
使用适用于 PHP的Google API 客户端库,我正在尝试创建一个新的日历事件并附加一个hangoutsMeet会议。当我尝试这样做时,我收到一条错误消息,指出Invalid conference type value.
使用相同的代码,我能够创建一个新事件并附加一个eventHangout会议。
我明白为什么我会收到错误消息:根据 API,我的日历只支持eventHangout会议类型。
<<<< 2020 年 4 月 3 日编辑 #1
根据Andres Duarte的回答进行澄清:这仅在我尝试通过 API 创建事件时才显示为限制。当我手动创建使用谷歌日历界面的事件,我是能够添加谷歌见面。事实上,这是下拉列表中显示的唯一会议选项。
>>>>
我的问题是,如何更新我的日历设置(使用或不使用 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;
}
Run Code Online (Sandbox Code Playgroud)
这是上面的输出:
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."
}
}
Run Code Online (Sandbox Code Playgroud)
额外细节:
在创建活动之前,您需要使用服务帐户凭据来模拟 G Suite 域中的用户,这样您就可以创建hangoutsMeet会议类型的活动,该活动仅适用于 G Suite 用户。
尽管您的服务帐户具有域范围的委派,但它不具有与 G Suite 用户相同的权限,根据文档:
与用户帐户不同,服务帐户不是 G Suite 域的成员。
在您的情况下,这就是为什么您只能创建eventHangout会议类型的事件,该类型适用于事件资源文档中所述的消费者:
可能的值为:
“eventHangout”,适用于消费者环聊 ( http://hangouts.google.com )
“eventNamedHangout”适用于 G Suite 用户的经典环聊 ( http://hangouts.google.com )
“hangoutsMeet”用于 Hangouts Meet ( http://meet.google.com )
3P 会议提供商的“addOn”
| 归档时间: |
|
| 查看次数: |
2223 次 |
| 最近记录: |