adding insult to injury

PHP and Apple’s URL Protocol Support

With the release of Panther (Mac OS 10.3) Apple has built in a new technology, called URL Protocol Support, that allows for a clickable link in a browser to launch Script Editor and populate it with a script. This makes it easier to share AppleScripts online.

On my handy little script section of Objective Labs I’ve just implemented support for this new feature.

Apple has an AppleScript that is sort of cumbersome in that you have to pre-convert your scripts into clickable links to put them online. If you’re a big geek like me, and you store your scripts in a database, it’s easy to use php to convert a script to a clickable url protocol link on the fly.

Just use this php code:

$yourScript = rawurlencode($the_variable_holding_your_script);

and place it in the scirpt portion of the link like this:

<a href=”applescript://com.apple.scripteditor?action=new&script=<?PHP echo $yourScript; ?>>The Link</a>

And you will end up with something like this:
Panther users click here to open this in script editor.