2011-06-29 69 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字段的值。