2016-07-29 7 views
0

すべてが既にGoogleカレンダーのapiに設定されています(正しく設定されていないか、何かを見逃しているかわかりません) Googleカレンダーに予定を書き込むC#コンソールアプリケーションを作成しました。C#Google Calendar

私が達成したいのは、自分のアプリを購読しているすべてのユーザーまたは加入者を取得したいからです。イベントがあれば、そこには を書くことができます。

どのような設定が必要ですか?以下は

答えて

-1

は、実際には、マルチドメイン問題だサンプルコード、

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); 
    } 
} 
+0

私のアプリを購読しているユーザーのリストを取得するにはどうすればよいですか? – PongPagong

+0

Google OAuth 2.0を使用して情報を取得してから処理する必要があります。 – Thennarasan

+0

すでにoAuth 2.0を適用しました。質問はどのように私は加入者のリストを取得するのですか – PongPagong

1

です。

考慮すべきいくつかの質問:

  1. それがどのようなカレンダーですか?公的なもの?
  2. コンソールにはどのように登録しますか?
  3. ソフトウェアがシャットダウンしたり、クラッシュしたりするとどうなりますか?
  4. のカレンダーに書き込んだ後、そのことを知る必要がありますか?
  5. そうでない場合は、新規加入者に以前に追加したカレンダーエントリを取得しますか?

Webclientをご覧ください。次に、Google Calendar APIのリファレンスがあります。あなたが探している主なリクエスト方法は、この1つです:Events Insert。それで、私たちは独自の改ざんを作り出すことができます。

`` `

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); 
    } 
} 

これは、最小限の例であり、APIは、エンドポイントとパラメータをたくさん持っています。あなたはそれを深く見て、より有用なパラメータを見つけるかもしれません。