-- PlazesWhereAmIApplescript 0.9 -- Allows you to grab your current Plazes (plazes.com) location given your Plazes username and password. -- This work is licensed under the Creative Commons Attribution License. To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. -- Set these to match your Plazes account set username to "username" set passwordPlain to "password" -- And away we go... -- First, use the /sbin/md5 command to calculate MD5 hash of the string PLAZES plus the password. This command should be installed by OS X (at least on Tiger) by default. try do shell script "/sbin/md5 -qs PLAZES" & passwordPlain on error errMsg number errNo error errMsg number errNo return "failed" end try set passwordMD5 to result -- Now that we've got the MD5 hash, we use Applescript's built-in XML-RPC client magic to communicate with the Plazes XML-RPC server... set PlazesData to TalktoPlazes(username, passwordMD5) if (PlazesData is "offline") then set theReply to display dialog "You are currently offline." buttons {"OK"} default button "OK" else -- And we grab the plazename and plazeurl; other things we *could* grab: -- username, plazestate, plazecountry, plazecity, plazelat, plazelon set plazename to plazename of PlazesData set plazeurl to plazeurl of PlazesData as text -- Obviously we could do lots of cool stuff here; for now, we just pop up a dialog box showing the current location. set theReply to display dialog "You are currently at " & plazename & "." buttons {"Go to Plazes", "OK"} default button "OK" -- If the user clicks on "Go to Plazes" then we tell Safari to open the Plazes URL. There are probably more elegant and universal ways of doing this. if button returned of theReply is "Go to Plazes" then tell application "Safari" set the URL of document 1 to plazeurl end tell end if end if -- This is the actual XML-RPC call to the Plazes server: on TalktoPlazes(username, passwordMD5) tell application "http://beta.plazes.com/xmlrpc/whereami.php" return call xmlrpc {method name:"plazes.whereami", parameters:{username, passwordMD5}} end tell end TalktoPlazes