【QR】イベント・カレンダー登録用のQRコードを作る(Google Chart利用)
iCalフォーマットのicsファイルをQRコードに変換します。
(*
make_qrcode4_eventfile.scpt
イベント登録用のQRを作成します。
たぶんiOS専用
20190714 初回作成
APIの仕様は
https://developers.google.com/chart/infographics/docs/qr_codes
*)
on run
set theWithPrompt to "QRコードを作成します。"
set theDefLoc to path to downloads folder from user domain
set theFileType to "public.vcard,com.apple.ical.ics" as text
set AppleScript's text item delimiters to {","}
set theFileTypeList to every text item of theFileType
open (choose file default location theDefLoc ¬
with prompt theWithPrompt ¬
of type theFileTypeList ¬
without invisibles)
end run
on open DropObj
set theFilePath to POSIX path of DropObj
set theChl to (do shell script "cat '" & theFilePath & "'") as text
set theChl to doReplace(theChl, "\r ", "") as text
set theChl to doReplace(theChl, "\"", "\\\"") as text
set theChl to my encodeURL(theChl) as text
set theChl to doReplace(theChl, "+", "%20") as text
--BASE URL
set theApiUrl to "https://chart.googleapis.com/chart?" as text
set theCht to "qr" as text
set theChs to "540x540" as text
set theChoe to "UTF-8" as text
---L M Q R
set theChld to "L" as text
--URLを整形
set theOpenUrl to ("" & theApiUrl & "&cht=" & theCht & "&chs=" & theChs & "&choe=" & theChoe & "&chld=" & theChld & "&chl=" & theChl & "") as text
-----サファリで開く
tell application "Safari"
activate
make new document with properties {name:"QR-CODE by Google API"}
tell window 1
open location theOpenUrl
end tell
end tell
end open
--------------文字の置き換えサブルーチン
to doReplace(theText, theOrgStr, theNewStr)
set theOldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to theOrgStr
set theTmpList to every text item of theText
set AppleScript's text item delimiters to theNewStr
set theReplaceStr to theTmpList as text
set AppleScript's text item delimiters to theOldDelim
return theReplaceStr
end doReplace
---URLエンコードのサブルーチン
on encodeURL(str)
set scpt to "php -r 'echo urlencode(\"" & str & "\");'"
return do shell script scpt
end encodeURL
ダウンロード - make_qrcode4_eventfile.zip
| 固定リンク
「Barcode2D」カテゴリの記事
- [LINE]QRコード各種(2023.08.29)
- 【QR】イベント・カレンダー登録用のQRコードを作る(Google Chart利用)(2022.01.06)
- 【QR】アドレス帳登録用のQRコードを作る(Google Chart利用)(2021.12.06)
- [Wifi]Wifiアクセスポイント用のmobileconfigを作成する(2021.11.02)
- [AppleScripts]WIFIバーコードを作成(データマトリックス)(2021.08.29)