« PostScript Nameの取得 | トップページ | 【QR】マップ用のQRコードを作る(Google Chart利用) »

【QR】イベント・カレンダー登録用のQRコードを作る(Google Chart利用)

Website_20190714193401

 

iCalフォーマットのicsファイルをQRコードに変換します。

 

 

192234

 

 


(*

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

 

 

 

 

 

 

 

|

« PostScript Nameの取得 | トップページ | 【QR】マップ用のQRコードを作る(Google Chart利用) »

Barcode2D」カテゴリの記事