SyntaxHighlighter

2012年1月19日木曜日

ファイルメーカー メールを受信 プラグイン - MailMakerPop+

ファイルメーカーで直接メールを受信可能にするプラグイン.
MailMakerPop+
http://manual-mailmakerpop.joy-h.com/
独自サブドメインになりました!


CNAME レコードの設定: ムームードメイン

http://support.google.com/a/bin/answer.py?hl=ja&answer=142022

Googleにマニュアルがあったのであっけなくサブドメイン登録が完了!
今後、http://manual-mailmakerpop.joy-h.com/のページは、マニュアル中心になります!

という事で、現在当社WEBデザイナーがMailMakerPop+のトップページを作ってくれています!


イイ感じです!



こっちの方がモット!イイ感じです!



2012年1月11日水曜日

Google Calendar API v3 OAuth2.0 C#

Google Calendar API v3

参考にさせて頂きました!
Google Calendar API v3 でカレンダーに予定を登録する
(事前準備としてプロジェクトを登録は、上記を参照)

Google APIs Client Library for .NET が必要!

 Google Calendar API v3 OAuth2.0のサンプル
using System;
using System.Diagnostics;
using DotNetOpenAuth.OAuth2;
using Google.Apis.Authentication;
using Google.Apis.Authentication.OAuth2;
using Google.Apis.Authentication.OAuth2.DotNetOpenAuth;
using Google.Apis.Calendar.v3;
using Google.Apis.Calendar.v3.Data;
using Google.Apis.Util;
...

  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";
      var auth = new OAuth2Authenticator<NativeApplicationClient>(provider, GetAuthorization);

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

      ...
  }

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

public static void Main(string[] args) 内 GetAuthorization がありません!
var auth = new OAuth2Authenticator<NativeApplicationClient>(provider, GetAuthorization);

いきなりエラー!
private static IAuthorizationState GetAuthentication(NativeApplicationClient arg)

GetAuthentication を GetAuthorization に変更
private static IAuthorizationState GetAuthorization(NativeApplicationClient arg)

コンソールが表示されるだけで何も起こりません!? ****.Fetch(); フェッチしないといけないようです。なので、以下を追加。

Calendar calendar = service.Calendars.Get("primary").Fetch();
Console.WriteLine(calendar.Summary);
Console.ReadKey();

using System;
using System.Diagnostics;
using DotNetOpenAuth.OAuth2;
using Google.Apis.Authentication;
using Google.Apis.Authentication.OAuth2;
using Google.Apis.Authentication.OAuth2.DotNetOpenAuth;
using Google.Apis.Calendar.v3;
using Google.Apis.Calendar.v3.Data;
using Google.Apis.Util;
...

  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";
      var auth = new OAuth2Authenticator(provider, GetAuthorization);

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

Calendar calendar = service.Calendars.Get("primary").Fetch();
Console.WriteLine(calendar.Summary);
Console.ReadKey();
  }

認証画面が出ました!


[アクセス許可]をクリックすると認証コードが表示されます。


このコードをコンソールに貼り付けて「Enter」
カレンダー名が表示されます。


しかし、この方法だと毎回「アクセス許可」をしないといけません!
ググっても情報が少ない!!!

RefreshToken を行えばOK!(これがわかるまでに相当な時間が...!)

"RefreshToken Code"は、最初の[アクセス許可](arg.ProcessUserAuthorization)を行なった時に取得できます。
※再度[アクセス許可](arg.ProcessUserAuthorization)を行うと"RefreshToken Code"は、変わってしまいます。


private static IAuthorizationState GetAuthorization(NativeApplicationClient arg)
        {
            IAuthorizationState state = new AuthorizationState(new[] { CalendarService.Scopes.Calendar.GetStringValue() });
            state.Callback = new Uri(NativeApplicationClient.OutOfBandCallbackUrl);

            //本来ならAccessTokenの期限切れならRefreshTokenを行う処理にしたいが、また今度!
            //https://www.googleapis.com/oauth2/v1/tokeninfo?access_token="AccessToken"

            state.RefreshToken = "RefreshToken Code";
            bool b = arg.RefreshToken(state);
            //成功したら true がかえってくる。

            return state;
        }

GCalenMakerファイルメーカー用プラグイン(Windows専用)
Googleカレンダーへイベントを追加,編集,削除。Googleカレンダーからイベントを読込。」
は、Google Calendar API v2を利用しているのでV3仕様に変更しないといけない...。

SyntaxHighlighter テスト

Console.Write("  Authorization Code: ");
string authCode = Console.ReadLine();
Console.WriteLine(); 

参考:http://moririn-web.blogspot.com/2011/12/bloggersyntaxhighlighter-ver3x.html