我正在尝试使用以下代码向Google日历添加活动时设置作者:
CalendarService service = new CalendarService("TestApp");
service.setUserCredentials("example@gmail.com", "1234");
EventEntry entry = new EventEntry();
// Set the title and content of the entry.
entry.Title.Text = "Test";
entry.Content.Content = "Test";
// Not working
AtomPerson author = new AtomPerson(AtomPersonType.Author);
author.Name = "John Doe";
author.Email = "john@example.com";
entry.Authors.Add(author);
When eventTime = new When(activity.Start, activity.End, activity.Start == activity.End ? true : false);
entry.Times.Add(eventTime);
Uri postUri = new Uri("https://www.google.com/calendar/feeds/default/private/full");
// Send the request and receive the response:
AtomEntry insertedEntry = service.Insert(postUri, entry);
除了作者之外,该事件还添加了所有正确的属性。作者仍然是日历的所有者。有什么想法吗?
答案 0 :(得分:1)
根据Calendar API文档(http://code.google.com/apis/calendar/data/2.0/developers_guide_protocol.html#CreatingSingle):
服务器将根据用户插入作者信息 提交请求(即其身份验证令牌的用户) 伴随请求)。
创建事件时无法设置“作者”字段的值。