2011-06-29 101 views
0

我想添加一个事件到谷歌日历使用此代码来设置作者:设置事件作者与谷歌日历API

 CalendarService service = new CalendarService("TestApp"); 
     service.setUserCredentials("[email protected]", "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 = "[email protected]"; 
     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); 

此次活动除了作者所有正确的属性添加得到。作者仍然是日历的所有者。有任何想法吗?

回答

1

按日历API文档(http://code.google.com/apis/calendar/data/2.0/developers_guide_protocol.html#CreatingSingle):

服务器将插入基于作者信息 提交该请求的用户(即,其认证令牌 伴随该请求的用户)。

创建事件时无法设置Author字段的值。