yourls

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 Action: Create Short URL with YOURLS

If you follow me on Twitter you may of noticed I’ve been using a custom URL shortener lately, I did this because I purchased matt.mx and got tiered of waiting for bitly.pro. After looking round I found YOURLS a set of PHP scripts that do most of the functions of bitly.pro and of course has the ability to create really short links without the 6 character hash. I might review this at a later date.

Now I did have a LaunchBar action to create bit.ly links that will work perfectly fine with bitly.pro however now I use YOURLS I needed to make a few modifications to support a new API and here is the new AppleScript for you to enjoy (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 YOURLS
     set login to "YOURURSERNAME"
     set apiKey to "YOURPASSWORD"
     set bitlyURL to "http://YOURDOMAIN/yourls-api.php?action=shorturl&format=simple&username=" & login & "&password=" & apiKey &
"&url=" & theURL & ""
     set results to do shell script "curl " & quoted form of bitlyURL

  -- Copy to clipboard and display
     tell application "LaunchBar"
       perform action "Copy" with string results
       display in large type results
     end tell

end handle_string

You will need to make 3 changes to allow this to work, firstly change YOURUSERNAME and YOURPASSWORD to your own username and password for your YOURLS install and secondly change YOURDOMAIN to point to the path of you yourls-api.php file.

Put the file in ~/Library/Application Support/LaunchBar and rename it to whatever you want the script to be activated by in LaunchBar.

Stay tuned to this page for update’s to this script as YOURLS grows

 Scroll to top