Fil on the road - My journey through the world of internet marketing
You are here: Home » Technical solutions » How to: Automatic URL Shortening with REDIR.EC and Textexpander

How to: Automatic URL Shortening with REDIR.EC and Textexpander

by filontheroad on April 26, 2009

in Technical solutions

Welcome back!

When you are dealing with space restrictions (like Twitter´s 140 character limit) URL shortening becomes just a big deal. Nower days there are a lot of different URL Shortening services out there, but the one i recommend is redir.ec . So i have been playing around a little bit in the last days with Applescript and Textexpander, because i always try to save time by using snippets through textexpander. Its like the shortcuts on your system, just configured as you want – and its damm easy and simple. So everybody can set it up very fast.

So here is what you can do if you want to use the redir.ec URL Shortening service and Textexpander to work together as a quick and easy tool.

So if you are working on MAC OS X and you tried out Textexpander, then you just can use this amazing redir.ec URL shortening service too.Just follow these steps:

1.) Open Textexpander from the system preference panel and create a new snippet (command – N)

2.) Choose on of the two following Applescript codes into the Content box:

Shorting a URL which you copied to the clipboard:

set the ClipURL to (the clipboard as string)

ignoring case
if ((characters 1 through 4 of ClipURL as string) is not “http”) then
return “Malformed URL.”
else
set curlCMD to ¬
“curl –stderr /dev/null \”http://redir.ec/_api/rest/redirec/create?url=” & ClipURL & ” \”"

– Run the script and get the result:
set redirec to (do shell script curlCMD)

return redirec
end if
end ignoring

Shorting a URL which you truncated to  your front Safari window:

tell application “Safari”

set PageURL to URL of front document

end tell

set curlCMD to ¬
“curl –stderr /dev/null \”http://redir.ec/_api/rest/redirec/create?url=” & PageURL & ” \”"

– Run the script and get the result:
set redirec to (do shell script curlCMD)

return redirec

3.) Above the box, you must change now the “Content: Plain Text” to “Content: AppleScript” so that we execute the script instead of replacing our text with the raw code.

4.) Set the Abbreviation. I use the “,” to start all form of commands in my Textexpander so i called the first abbreviation “,sredirec” (copied URl to clipboard) and the second one i called “,sredirec” (truncating the Safari front window).

So enjoy it and have fun posting your url through redir.ec using textexpander.

Readers who read this article, also read:

DeliciousStumbleUponDiggTwitterMixxTechnoratiFacebookNews VineRedditLinkedInYahoo! BookmarksSphinn It!HyvesEmail

Leave a Comment

Previous post:

Next post: