2017年6月25日日曜日

FileMaker 15以前 から LINE へ 通知 LINE Notify 2|Event を送信

FileMaker 15以前

スクリプト Event を送信 を使用するので ほとんどのFileMaker で動作します。

対象OS:Windows 7以降
※PowerShellをインストールすれば OS Xでも大丈夫かも。(20170625時点、未検証)
https://github.com/PowerShell/PowerShell


LINE Notify
https://notify-bot.line.me/ja/

LINE Notify でアクセストークン を取得しておく。

スクリプト例:
変数を設定 [$PowerShell; 値:
"Add-Type -AssemblyName System.Web;
$encode = [System.Text.Encoding]::UTF8;
$headers = @{'Authorization' = 'Bearer アクセストークン'};
$body='message='+[System.Web.HttpUtility]::UrlEncode('こんにちわ',$encode);
$return=Invoke-RestMethod -Method POST -Uri https://notify-api.line.me/api/notify -Headers $headers -body $body;
$return;"
]
Event を送信 [「aevt」; 「odoc」; "powershell -windowstyle hidden -Command " & $PowerShell]


上記の方法では、スクリプト Event を送信 で、投げっぱなしになり戻り値の取得ができ無いので、送信に成功したかどうか分かりません。
ScriptMakerPS を使用することで戻り値の取得が出来ます。(Winのみ)

Event を送信 [「aevt」; 「odoc」; "powershell -windowstyle.....
の部分をいかに置き換えます。

変数を設定 [$Result; 値: SMPS_Exe( $PowerShell )]

ScriptMakerPS | FileMaker Plugin for Windows : https://sites.google.com/site/scriptmakerps/

FileMaker 15以前 から LINE へ 通知 LINE Notify

FileMaker 15以前

スクリプト URLから挿入 を使用するので FileMaker 12以降で動作します。

FileMaker 16 に移行しやすいように cURL を使用。



必要なもの
cURL
https://curl.haxx.se/
(Macの場合は、標準なのでインストール不要)
Windowsの場合、今回の例では、curl.exe を C:\curl\curl.exe に保存。

ProcessMakerTL(プロセス メーカー ティー エル)
https://sites.google.com/site/processmakertl/


LINE Notify
https://notify-bot.line.me/ja/

LINE Notify でアクセストークン を取得しておく。


フィールド:Setting::cURL_exe_Path
値:C:\curl\curl.exe (Windows)
(Mac OS X の場合は、curl でOK)

ProcessMakerTL.exe を起動しておく。
Windowsの場合は、ProcessMakerTL.exeをダブルクリックで起動。
Mac OS X の場合は、以下を参照。
Mac OS X - ProcessMakerTL : https://sites.google.com/site/processmakertl/mac-os-x

スクリプト例:

変数を設定 [$URL; 値: "https://notify-api.line.me/api/notify"]
変数を設定 [$cURL_option 値:
Let([
¢option="
--request POST
--header \"Authorization:Bearer {api_token}\"
--data-binary \"message={messages}\""
];
Substitute ( ¢option ;
  ["{api_token}" ; "{アクセストークン}"]
 ; ["{messages}" ; GetAsURLEncoded ( "こんにちわ¶こんばんわ" ) ]
 )
)
]
#ProcessMakerTL経由で送信
変数を設定 [$URi 値:
Let([
¢URi="{host}?target={target}&Arguments={Arguments}&StandardOutputEncoding={StandardOutputEncoding}&ResponseContentType={ResponseContentType}&access_token={access_token}"
];
Substitute ( ¢URi ;
["{host}" ; "http://localhost:8081/" ]
; ["{target}" ; GetAsURLEncoded ( Setting::cURL_exe_Path ) ]
; ["{Arguments}" ; GetAsURLEncoded (  $cURL_option & " " & $URL ) ]
; ["{StandardOutputEncoding}" ; GetAsURLEncoded (  "UTF-8" ) ]
; ["{ResponseContentType}" ; GetAsURLEncoded (  "text/plain"  ) ]
; ["{access_token}" ; "" ]
)

)
]
URLから挿入 [選択; ダイアログあり:オフ; cURL::Result; $URi; URLを自動的にエンコードしない]

FileMaker 16 から LINE へ 通知 LINE Notify

FileMaker 16

LINE Notify
https://notify-bot.line.me/ja/

LINE Notify でアクセストークン を取得しておく。

スクリプト例:

変数を設定 [$URL; 値: "https://notify-api.line.me/api/notify"]
変数を設定 [$cURL_option 値:
Let([
¢option="
--request POST
--header \"Authorization:Bearer {api_token}\"
--data-binary \"message={messages}\""
];
Substitute ( ¢option ;
  ["{api_token}" ; "{アクセストークン}"]
 ; ["{messages}" ; GetAsURLEncoded ( "こんにちわ¶こんばんわ" ) ]
 )
)
]
URLから挿入 [選択; ダイアログあり:オフ; cURL::Result; $URL; cURL オプション:$cURL_option;URLを自動的にエンコードしない]