AppleScript名:Returns the value in BTC |
— Created 2017-12-24 by Takaaki Naganoya — 2017 Piyomaru Software use AppleScript version "2.5" use scripting additions use framework "Foundation" property |NSURL| : a reference to current application’s |NSURL| property NSData : a reference to current application’s NSData property NSJSONSerialization : a reference to current application’s NSJSONSerialization set aInfo to retValueInBTC("JPY", "10000") of me –> "0.00654764" on retValueInBTC(aCurrency, aVal) set aRec to {currency:aCurrency, value:aVal} set reqURLStr to "https://blockchain.info/tobtc" set aURL to retURLwithParams(reqURLStr, aRec) of me try with timeout of 10 seconds set curl_command to "curl " & quoted form of aURL set jRes to do shell script curl_command return jRes end timeout on error return missing value end try end retValueInBTC on retURLwithParams(aBaseURL, aRec) set aDic to current application’s NSMutableDictionary’s dictionaryWithDictionary:aRec set aKeyList to (aDic’s allKeys()) as list set aValList to (aDic’s allValues()) as list set aLen to length of aKeyList set qList to {} repeat with i from 1 to aLen set aName to contents of item i of aKeyList set aVal to contents of item i of aValList set the end of qList to (current application’s NSURLQueryItem’s queryItemWithName:aName value:aVal) end repeat set aComp to current application’s NSURLComponents’s alloc()’s initWithString:aBaseURL aComp’s setQueryItems:qList set aURL to (aComp’s |URL|()’s absoluteString()) as text return aURL end retURLwithParams |
More from my site
(Visited 17 times, 1 visits today)