| |
まず、秀丸アドレス帳シンクロナイザのVersion 1.05β2をアップロードしました。これをインストールして欲しいです。
http://hide.maruo.co.jp/software/bin3/tkgc105b2_signed.exe
インストールして実行してタスクトレーのアイコンで右ボタンを押すと、
テスト用:アクセストークンの取得
ってコマンドがあるのでそれを実行します。そうすると、「取得したアクセストークンをクリップボードにコピーします。....」みたいなメッセージが出るはずになります。それが正常動作するか確認します。
次に、秀丸エディタのマクロとして、以下のようなのを1つ作ります。
-----GoogleContactTest.mac-------------------------------
//ここを書き換える
$accessToken = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
setcompatiblemode 0x00000200; //検索でヒットした文字列を範囲選択する。
#http = createobject( "Msxml2.XMLHTTP" );
if( #http == 0 ) {
#http = createobject( "Microsoft.XMLHTTP" );
if( #http == 0 ) {
message "XMLHTTPオブジェクトの生成に失敗しました。";
endmacro;
}
}
menu "すべての連絡先を取得するテスト",
"2016年以降に更新された連絡先のみ取得するテスト",
"グループ一覧の取得テスト";
if( result == 1 ) {
goto Label_RetrieveAllContacts;
} else if( result == 2 ) {
goto Label_Retrieve2016OnlyContacts;
} else if( result == 3 ) {
goto Label_RetrieveAllContactGroups;
}
endmacro;
//すべての連絡先を取得するテスト
//
Label_RetrieveAllContacts:
$url = "https://www.google.com/m8/feeds/contacts/default/full";
callmethod #http, "open", "GET", $url, false;
callmethod #http, "setRequestHeader", "Authorization", "Bearer " + $accessToken;
callmethod #http, "setRequestHeader", "GData-Version", "3.0";
callmethod #http, "send", "";
$resp = getpropstr( #http, "responseText" );
newfile;
insertfix $resp;
question "メールアドレスだけ抽出しますか?";
if( result != yes ) {
endmacro;
}
gofiletop;
#i = 0;
while(1) {
searchdown "(?<=<gd:email .*?address=\\').+?(?=\')", regular, nocasesense;
if( !result ) {
break;
}
$email[#i] = gettext( seltopx, seltopy, selendx, selendy );
#i = #i + 1;
}
#count = #i;
if( #count == 0 ) {
message "メールアドレスは1つもありませんでした。";
endmacro;
}
gofiletop;
beginsel;
gofileend;
delete;
#i = 0;
while( #i < #count ) {
insert $email[#i] + "\n";
#i = #i + 1;
}
endmacro;
//2016年以降の連絡先を取得するテスト
//
Label_Retrieve2016OnlyContacts:
$url = "https://www.google.com/m8/feeds/contacts/default/full?update-min=2016-01-01T00:00:00";
callmethod #http, "open", "GET", $url, false;
callmethod #http, "setRequestHeader", "Authorization", "Bearer " + $accessToken;
callmethod #http, "setRequestHeader", "GData-Version", "3.0";
callmethod #http, "send", "";
$resp = getpropstr( #http, "responseText" );
newfile;
insertfix $resp;
question "メールアドレスだけ抽出しますか?";
if( result != yes ) {
endmacro;
}
gofiletop;
#i = 0;
while(1) {
searchdown "(?<=<gd:email .*?address=\\').+?(?=\')", regular, nocasesense;
if( !result ) {
break;
}
$email[#i] = gettext( seltopx, seltopy, selendx, selendy );
#i = #i + 1;
}
#count = #i;
if( #count == 0 ) {
message "2016年以降に更新されたメールアドレスは1つもありませんでした。";
endmacro;
}
gofiletop;
beginsel;
gofileend;
delete;
#i = 0;
while( #i < #count ) {
insert $email[#i] + "\n";
#i = #i + 1;
}
endmacro;
//グループ一覧の取得テスト
//
Label_RetrieveAllContactGroups:
$url = "https://www.google.com/m8/feeds/groups/default/full";
callmethod #http, "open", "GET", $url, false;
callmethod #http, "setRequestHeader", "Authorization", "Bearer " + $accessToken;
callmethod #http, "setRequestHeader", "GData-Version", "3.0";
callmethod #http, "send", "";
$resp = getpropstr( #http, "responseText" );
newfile;
insertfix $resp;
question "グループ名だけ抽出しますか?";
if( result != yes ) {
endmacro;
}
gofiletop;
#i = 0;
while(1) {
searchdown "(?<=<title>).+?(?=</title>)", regular, nocasesense;
if( !result ) {
break;
}
$group[#i] = gettext( seltopx, seltopy, selendx, selendy );
#i = #i + 1;
}
#count = #i;
if( #count == 0 ) {
message "2016年以降に更新されたメールアドレスは1つもありませんでした。";
endmacro;
}
gofiletop;
beginsel;
gofileend;
delete;
#i = 0;
while( #i < #count ) {
insert $group[#i] + "\n";
#i = #i + 1;
}
endmacro;
-----GoogleContactTest.macおわり-------------------------
マクロの先頭に$accessToken = "xxxxx..."って部分がありますが、ここに、秀丸アドレス帳シンクロナイザで取得したアクセストークンを貼り付けていただきますと、約1時間程度テストが可能になります。
で、マクロを実行して、出てくるメニューを選択してテストしてみて欲しいです。
それでうまく連絡先の一覧やグループの一覧が取得できるかどうか。取得できないとしたら、他のパソコンでテストした時と結果がどう違うのか、その辺の情報を全部取って僕に送っていただければ、こちらで何がおかしいのか判断できると思います。
ただ、僕の所に送っていただくと連絡先が全部丸わかりになってしまうので・・・僕に送っていただくよりは、ご自身で見て何が違うか判断していただく作戦の方がいいような気がします。例えばデータが途中で切れてるとか、メールアドレスの入るべき所が入って無いとか・・・。
もし、問題のパソコンでもまったくもって正常動作するとしたら、マクロでやってることをアドレス帳シンクロナイザでも再現させて、それで改めてテストしていただきたいと思います。それでも正常なら、Google Contacts APIの「.NET Framework用のライブラリ」自体が信用できないってことになるので、今回のような「https:」のアクセスを独自にやって対応するしか無いかもしれません。
-------------
あともう1点ありました。今回のV1.05β2から、Google用のライブラリのバージョンが、以前は2.1だったのが2.2になってます。これでもしかしたら正常になってるかもしれません。マクロで正常動作する場合はシンクロナイザの動作も改めてテストしてみて欲しいです。
|
|