Automate Bit.ly with AppleScript

A couple more AppleScripts, these help you turn a long URL into a short one using bit.ly. For even more usefulness use Quicksilver triggers or similar to bind these to a hotkey.

Grabs URL from Safai:

tell application "Safari"
    set longURL to (get URL of front document)
end tell

do shell script "curl http://bit.ly/api?url=" & longURL
set shortURL to the result

set the clipboard to (shortURL as text)

Grabs URL from the clipboard:

set longURL to (the clipboard as text)

do shell script "curl http://bit.ly/api?url=" & longURL
set shortURL to the result

set the clipboard to (shortURL as text)

4 thoughts on “Automate Bit.ly with AppleScript

  1. Just a note though, bit.ly changed their API. You need to add in login and API key, so add in these up top

    Editor’s Note: account and API key deleted due to unknown privacy issues. If an API key is required you may have to create an account.

    and change shell script line to this:

    do shell script “curl http://bit.ly/api?url=” & longURL & “&login=” & login & “&apiKey=” & apiKey

  2. Pingback: Shortening URLs via bit.ly from the CLI - blog.scottlowe.org - The weblog of an IT pro specializing in virtualization, storage, and servers

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>