plugin

YOURLS Plugin: Skimlinks

I’ve been using YOURLS as a custom URL shortener for some time now and I’ve been using Skimlinks to monetize my site for a little longer but until now it was a long process to create short links with my affiliate codes embedded.

When YOURLS 1.5 came out with support for plugins I decided to build my own to push all links shortened there through Skimlinks to add an alternative revenue stream and automatically embed affiliate code in every supported URL I shorten, a lot easier that before.

I have also made the decision to to publish the plugin and licence to code under the GPL.

The plugin is incredibly simple and doesn’t get in the way. In fact setting up the plugin is the most complex part.

Setup and Installation

  1. Download the plugin
  2. open plugin.php in your chosen text editor
  3. change YOURURL to your Skimlinks custom URL or redirect.skimlinks.com if you don’t have a custom one.
  4. change YOURID to your Skimlinks site ID (you can find this here, on your account setting page)
  5. save the file and upload the skimlinks folder to /user/plugins
  6. go to the plugins page in your YOURLS admin interface and activate the plugin

You can test if it works by entering one of your short URLS on longurl.org and expnading the redirect details.

LaunchBar Script: Create bit.ly

I recently created and published a LaunchBar Action to create and copy a bit.ly URL to the clipboard and today I wanted to use the URL in a SMS, a new script would be needed to display the new shortened URL.

Not a big change from my first script but still worth publishing, in this version I display and copy the URL to the clipboard, download here.

on handle_string(theURL)

-- add scheme prefix if missing
set _firstColon to offset of ":" in theURL
set _firstSlash to offset of "/" in theURL
if (_firstColon = 0 or _firstSlash < _firstColon) then
set theURL to "http://" & theURL
end if
-- Process and encode URL
set theURL to do shell script "/usr/bin/python -c 'import sys, urllib; print urllib.quote(sys.argv[1])' " & quoted form of theURL
-- Create bit.ly
set login to "YOOURUSERNAME"
set apiKey to "YOURAPIKEY"
set bitlyURL to "http://api.bit.ly/shorten?version=2.0.1&longUrl=" & theURL & "&login=" & login & "&apiKey=" & apiKey & ""
set results to do shell script "curl " & quoted form of bitlyURL & " | grep shortUrl | awk '{print $2}' | sed 's/[\",]//g'"
-- Copy to clipboard and display
tell application "LaunchBar"
perform action "Copy" with string results
display in large type results
end tell

end handle_string

Again replace "YOURUSERNAME" and "YOURAPIKEY" with your own details and install the action by placing the file in ~/Library/Application Support/LaunchBar/Actions.

If you do not want to copy the URL as well remove the line “perform action "Copy" with string results".

LaunchBar Script: Copy as bit.ly

I recently started using LaunchBar which comes with a Copy as TinyURL action built in however I use bit.ly. After searching around for a little while I found a script that posts to Twitter with bit.ly URL shorting but that was it.

I decided to take parts of both of these scripts to make my own and here is the code (download):

on handle_string(theURL)

-- add scheme prefix if missing
set _firstColon to offset of ":" in theURL
set _firstSlash to offset of "/" in theURL
if (_firstColon = 0 or _firstSlash < _firstColon) then
set theURL to "http://" & theURL
end if
-- Process and encode URL
set theURL to do shell script "/usr/bin/python -c 'import sys, urllib; print urllib.quote(sys.argv[1])' " & quoted form of theURL
-- Create bit.ly
set login to "YOOURUSERNAME"
set apiKey to "YOURAPIKEY"
set bitlyURL to "http://api.bit.ly/shorten?version=2.0.1&longUrl=" & theURL & "&login=" & login & "&apiKey=" & apiKey & ""
set results to do shell script "curl " & quoted form of bitlyURL & " | grep shortUrl | awk '{print $2}' | sed 's/[\",]//g'"
-- Copy to clipboard
tell application "LaunchBar"
perform action "Copy" with string results
end tell
end handle_string

Replace “YOURUSERNAME” and “YOURAPIKEY” with your own details.

To install the action place the file in ~/Library/Application Support/LaunchBar/Actions.

I have never written any AppleScript before and now I understand just how powerful it is I’m going to start learning the language.

 Scroll to top