2

我一辈子都找不到如何在我的视图中显示日历。我可以编写代码 我只是喜欢使用新 API 和剃刀视图在 iframe 中显示日历的示例

这是来自谷歌的代码。问题是AuthenticatorFactory ..它不存在。如果你让类在 .dll 之外使用,它还会引用不存在的类,以及带有不正确参数的方法。

我显然没有使用“Main”方法,但是由于authorizationfactory和其他几个缺少的类/方法,无法实现此代码

   public static void Main(string[] args)
  {
      // Register the authenticator. The Client ID and secret have to be copied from the API Access
      // tab on the Google APIs Console.
      var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description);
      provider.ClientIdentifier = "YOUR_CLIENT_ID";
      provider.ClientSecret = "YOUR_CLIENT_SECRET";
      AuthenticatorFactory.GetInstance().RegisterAuthenticator(
              () => new OAuth2Authenticator(provider, GetAuthentication));

      // Create the service. This will automatically call the previously registered authenticator.
      var service = new CalendarService();


  }

  private static IAuthorizationState GetAuthentication(NativeApplicationClient arg)
  {
      // Get the auth URL:
      IAuthorizationState state = new AuthorizationState(new[] { CalendarService.Scopes.Calendar.GetStringValue() });
      state.Callback = new Uri(NativeApplicationClient.OutOfBandCallbackUrl);
      Uri authUri = arg.RequestUserAuthorization(state);

      // Request authorization from the user (by opening a browser window):
      Process.Start(authUri.ToString());
      Console.Write("  Authorization Code: ");
      string authCode = Console.ReadLine();
      Console.WriteLine();

      // Retrieve the access token by using the authorization code:
      return arg.ProcessUserAuthorization(authCode, state);
  }
4

1 回答 1

2

我建议永远不要推荐 Google 的 Calender API 3 for .NET,我只是使用 Python。他们的文档对于其他一切都是可笑的。

于 2012-10-17T18:54:50.390 回答