为什么显示名称未显示在日历事件与会者中? [英] Why is Display Name is not Showing in Calendar Event Attendees?

查看:68
本文介绍了为什么显示名称未显示在日历事件与会者中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码摘要成功检索了日历事件参与者:

I'm successfully retrieving Calendar Event Attendees using the following code gist:

require_once __DIR__ . '/vendor/autoload.php';
putenv("GOOGLE_APPLICATION_CREDENTIALS=" .  __DIR__ . '/mt-service-account.json');

$client = new Google_Client();
$client->useApplicationDefaultCredentials();
$client->setApplicationName("APP NAME");
$client->setSubject("<APPROPRIATE_USER_EMAIL>");
$client->setScopes([
    'https://www.googleapis.com/auth/calendar'
]);

$calendarService = new Google_Service_Calendar($client);

$optParams = array(
    'singleEvents' => true,
    'orderBy'      => 'startTime'
);
$events = $calendarService->events->listEvents('<APPROPRIATE_CALENDAR_ID>', $optParams);

foreach ($events->getItems() as $event) {
  print_r($event->getAttendees());
}

但是,从响应中可以看出,没有返回显示名称.

However, as can be seen in the response, no Display Name is returned.

Array
(
    [0] => Google_Service_Calendar_EventAttendee Object
        (
            [additionalGuests] => 
            [comment] => 
            [displayName] => 
            [email] => johnsmith@domain.com
            [id] => 
            [optional] => 
            [organizer] => 
            [resource] => 
            [responseStatus] => needsAction
            [self] => 
            [internal_gapi_mappings:protected] => Array
                (
                )

            [modelData:protected] => Array
                (
                )

            [processed:protected] => Array
                (
                )

        )
)

有问题的与会者是事件创建者的联系人,并且在创建事件时,该联系人的姓名和电子邮件会显示在类型帮助字段中.

The attendee in question is a Contact of the event creator and the Contact's name and email appear in the type assist field when creating an event.

更新 NB 事件不是通过API创建的.它们是通过Google日历(即在浏览器中)创建的.通过在添加与会者"字段中键入与会者的姓名来添加与会者(Google类型助手找到了联系人).目的是通过编程方式(即使用API​​)检索由我们的G Suite日历用户创建的事件详细信息

UPDATE NB Events are not created via API. They're created via Google Calendar (i.e. in browser). The attendees are added by typing the attendee's name in the Add Attendee field (Google type-assist found the Contact). The aim is to retrieve programmatically (i.e. with API) event details created by our G Suite Calendar users

推荐答案

我看不到您如何创建有问题的活动,但我的猜测是创建活动并添加与会者的显示名称时不会插入可选参数.

I cant see how you are creating the event in question but my guess is that when the event was created and the attendee added their display name was not inserted as an optional parameter.

Events.insert

与会者[] .displayName字符串与会者的姓名(如果有).选修的.可写的

attendees[].displayName string The attendee's name, if available. Optional. writable

通过Google日历网络视图创建事件时,您只需添加用户的电子邮件地址即可.如果该用户是Gmail帐户,则Google可以猜测显示名称.如果不是Gmail帐户,则google无法知道用户名,因此显示名称为null.

When events are creted via the Google Calendar web view you just add a users Email address. In the event that said user is a Gmail account then Google can guess the display name. In the event it is not a Gmail account then google has no way of knowing what the users name is there for you end up with a display name of null.

attendees": [
    {
     "email": "lme@gmail.com",
     "displayName": "Linda Lawton",
     "organizer": true,
     "self": true,
     "responseStatus": "accepted"
    },
    {
     "email": "ll@meAtWork.com",
     "responseStatus": "needsAction"
    }

这篇关于为什么显示名称未显示在日历事件与会者中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆