Quantcast
Channel: Planet DTP@jp
Viewing all articles
Browse latest Browse all 4822

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

$
0
0

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 todownloads folderfromuser 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 filedefault locationtheDefLoc¬
with prompttheWithPrompt¬
of typetheFileTypeList¬
without invisibles)
end run



on openDropObj
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
makenewdocumentwith properties {name:"QR-CODE by Google API"}
tell window 1
open locationtheOpenUrl
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 scriptscpt
end encodeURL

 

 

ダウンロード - make_qrcode4_eventfile.zip

 

 

 

 

 

 

 


Viewing all articles
Browse latest Browse all 4822

Trending Articles