[英]C# Google Calendar
Everything is already setup on the google calendar api (not sure if i configure correctly or i missed something out) I created ac# console application,that writes an appointment to google calendar. 一切都已经在Google日历api上设置好了(不确定我是否配置正确或错过了什么),我创建了一个ac#控制台应用程序,该应用程序将约会写入了Google日历。
What i want to achieve is that , i want to get all the user's or subscriber who subscribe to my app, so what i can write on there calendar if there is an event. 我想要实现的是,我希望获得所有订阅我的应用程序的用户或订户,因此,如果发生事件,我可以在日历上写些什么。
What configuration do i need? 我需要什么配置?
That's actually a multi-domain problem. 这实际上是一个多域问题。
Some questions to consider: 需要考虑的一些问题:
Other than that, you should have a look at Webclient . 除此之外,您还应该看看Webclient 。 Then we have here the reference for the Google Calendar API .
然后,我们这里有Google Calendar API的参考。 The main request method you're searching is this one: Events Insert .
您要搜索的主要请求方法是: Events Insert 。 With that, we can craft our own inseration variant.
这样,我们就可以制作自己的inseration变体。
``` ```
private readonly List<string> _calendarIDs;
/* lets assume you imported webrequests and you're going to write a method
* Further we assume, you have a List of calendars as object attribute
*/
public void InsertEntry(DateTime start, DateTime end,
string title, string description) {
using(var client = new WebClient()) {
var epochTicks = new DateTime(1970, 1, 1);
var values = new NameValueCollection();
values["attachements[].fileUrl"] = "";
values["attendees[].email"] = "";
values["end.date"] = end.ToString("yyyy-MM-dd");
values["end.dateTime"] = (end - epoch).Seconds;
values["reminders.overrides[].minutes"] = 0;
values["start.date"] = start.ToString("yyyy-MM-dd");
values["start.dateTime"] = (start - epoch).Seconds;
values["summary"] = title; // This is the calendar entrys title
values["description"] = description;
foreach(string calendarID in _calendarIDs) {
var endpoint = String.Format("https://www.googleapis.com/calendar/v3/calendars/{0}/events", calendarID)
var response = client.UploadValues(endpoint, values);
var responseString = Encoding.Default.GetString(response);
}
}
This is a minimal example and the api has a lot of endpoints and parameter. 这是一个最小的示例,并且api有很多端点和参数。 You should have a deep look into it, maybe you find more useful parameter.
您应该对此进行深入研究,也许您会找到更有用的参数。
Below is the sample code, 下面是示例代码,
GoogleCalendarUtils utils = new GoogleCalendarUtils();
ArrayList months = /* the list of months*/;
// Update the content window.
foreach( ThistleEventMonth month in months )
{
foreach( ThistleEvent thistleEvent in month.ThistleEvents )
{
utils.InsertEntry( thistleEvent );
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.