|
|
Combine POST with Keychain
This is great -- works beautifully. However, I ended up combining the Dial-with-Vonage-0.3 script (halfway up the comments), that POSTs the username and password, and the idea of using the keychain to store them (near the bottom of comments). Think this is as secure as you can make this. The resulting script looks like this:
(* Automatic Vonage Dialer v0.5 Major Changes by Patrick Tescher, pat2man@comcast.net Based on: Automatic Vonage Dialer v0.2 Aaron Freimark, abf@mac.com March 16, 2004 Put this script into your "Address Book Plugins" folder in your ~/Library folder. Only works in the US with this version *) property keyName : "Vonage" -- The lines below are correct for the U.S. property myCountryCode : "1" property myLongDistanceCode : "1" property myIntlAccessCode : "011" using terms from application "Address Book" on action property return "phone" end action property on action title for pers with fone return "Dial with Vonage" end action title on should enable action for pers with fone if label of fone contains "fax" then return false return true end should enable action on perform action for pers with fone set theKey to GetKeyNamed(keyName) -- set theKey to myVonageKey if theKey is null then set theKey to CreateKey(keyName) end if tell application "Keychain Scripting" set myVonageLogin to account of theKey set myVonagePassword to password of theKey end tell set NumberList to GetNumbers(myVonageLogin, myVonagePassword) if (count of NumberList) is greater than 1 then set myVonageNumber to GetDefaultNumber(comment of theKey, NumberList) if myVonageNumber is null then set myVonageNumber to SelectNumber(NumberList) end if else set myVonageNumber to item 1 of NumberList end if set theNumber to (value of fone) as string -- Add the long distance or international access code if it's not already there. set numToDial to InsertLDCodes(theNumber) --Uncomment the following two lines to confirm the number --display dialog "So you want me to call?" default answer numToDial buttons {"OK"} --set numToDial to text returned of the result --Erase everything that's not a digit from the phone number set cleanedNumber to CleanTheNumber(numToDial) set theURL to "https://secure.click2callu.com/tpcc/makecall" set theData to " -d username=" & myVonageLogin set theData to theData & " -d password=" & myVonagePassword set theData to theData & " -d fromnumber=" & myVonageNumber set theData to theData & " -d tonumber=" & cleanedNumber -- Use curl to hit the URL and dial the number set errorCode to do shell script "curl \"" & theURL & "\"" & theData --If there was an error, return a message. if (characters 1 thru 3 of errorCode) as string ≠"000" then display dialog "Error: " & errorCode buttons {"OK"} end if end perform action end using terms from on InsertLDCodes(theNumber) if (characters 1 thru 2 of theNumber) as string = "+" & myCountryCode then -- The number was formatted correctly. return theNumber end if if character 1 of theNumber = myLongDistanceCode then -- Domestic long distance with LD access code return theNumber end if if character 1 of theNumber = "+" then -- international number, add prefix return myIntlAccessCode & " " & theNumber end if -- local number, must add the LD code for Vonage return myLongDistanceCode & " " & theNumber end InsertLDCodes on CleanTheNumber(numToDial) -- remove punctuation from a string, leaving just the number set theDigits to {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"} set cleanedNumber to "" repeat with i from 1 to length of numToDial set j to (character i of numToDial) if j is in theDigits then set cleanedNumber to cleanedNumber & j end repeat return cleanedNumber end CleanTheNumber on GetKeyNamed(keyName) tell application "Keychain Scripting" try tell current keychain get some generic key whose name is keyName return result end tell on error return null end try end tell end GetKeyNamed on CreateKey(keyName) tell application "Address Book" display dialog "Enter Username" default answer "username" buttons {"OK"} default button "OK" set myVonageLogin to text returned of the result display dialog "Enter Password" default answer "password" buttons {"OK"} default button "OK" set myVonagePassword to text returned of the result display dialog "Enter Vonage Number" default answer "15555555555" buttons {"OK"} default button "OK" set myVonageNumber to text returned of the result (* set VonageNumbers to GetNumbers(myVonageLogin, myVonagePassword) if (count of VonageNumbers) is 1 then set myVonageNumber to item 1 of VonageNumbers else set myVonageNumber to null end if *) end tell tell application "Keychain Scripting" tell current keychain make new generic key with properties ¬ {name:keyName, account:myVonageLogin, password:myVonagePassword, comment:"Default Number: " & myVonageNumber} return result end tell end tell end CreateKey on GetDefaultNumber(comments, VonageNumbers) set theNumber to null repeat with currentWord in VonageNumbers if currentWord is in comments then set theNumber to currentWord end if end repeat return theNumber end GetDefaultNumber on GetNumbers(login, pass) set theURL to "https://secure.click2callu.com/tpcc/getnumbers?" set theURL to theURL & "username=" & login set theURL to theURL & "&password=" & pass set errorCode to do shell script "curl \"" & theURL & "\"" return words in errorCode end GetNumbers on SelectNumber(NumberList) tell application "Address Book" display dialog "Choose a number" buttons NumberList return button returned of result end tell end SelectNumber |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:Hints1 new Hints in the last 24 hoursComments last 2 daysNo new commentsLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.18 seconds |
|