• This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

Shorten URL Services

Jeremy

in memoriam 1991-2020
Cezz and I have been hard at work creating a high quality, powerful helper library for both users and developers alike. We would like to present the Shorten URL services library!

For the end user / administrator (see third post for list of add-ons using our library):
  • Powerful control over which methods are available (at least those that require options)
  • Choice of default shortener
  • Enable / Disable shortening services
  • Install / Uninstall advanced shorteners
  • Easy install of new methods (requires a new file upload, thats it!)
For the developer (see second post for developer documentation):
  • Easy implementation (may call 1 function and support them all, or go advanced and support all available as options)
  • Powerful development features (of new methods)
  • Simple loading of methods / calling the correct shortener
  • Testing suite (secondary add-on found in /library/Shorten/Test/)
And, out of the box, our library supports the following services:
  1. Awe.sm
  2. Bit.ly
  3. Cli.gs
  4. Goo.gl
  5. Is.gd
  6. Kwn.me (Default shortener)
  7. No Shortening (to allow disabling of the service unless specified by code)
  8. Quicklink.me (No longer a separate module, but can be set to work via kwn.me's settings)
  9. Simple URL shortening (removes the title from links for your board specifically)
  10. TinyURL
  11. Ur.ly
Would you like to see more? Leave a comment below. Developing one you'd like included? Post it below!

Installation:

Installing this library is as easy as uploading the files to your library directory, and importing the addon_shortenURL.xml file. :) Then, set up options as you require/wish.

Change Log:
v1.0.1:
- Updated Kwn.me to include an optional setting (kwn.me's URL parameter) after speaking with its owners: Mikey & Floris.
 

Attachments

  • Shorten.zip
    Shorten.zip
    22.1 KB · Views: 74
  • Screen shot 2010-10-24 at 6.40.05 PM.webp
    Screen shot 2010-10-24 at 6.40.05 PM.webp
    31.2 KB · Views: 172
  • Screen shot 2010-10-24 at 6.40.19 PM.webp
    Screen shot 2010-10-24 at 6.40.19 PM.webp
    31.4 KB · Views: 148
  • Screen shot 2010-10-24 at 6.40.31 PM.webp
    Screen shot 2010-10-24 at 6.40.31 PM.webp
    14.8 KB · Views: 144
  • Screen shot 2010-10-24 at 6.40.45 PM.webp
    Screen shot 2010-10-24 at 6.40.45 PM.webp
    12.3 KB · Views: 138
  • Screen shot 2010-10-24 at 6.40.55 PM.webp
    Screen shot 2010-10-24 at 6.40.55 PM.webp
    31.3 KB · Views: 124
  • Screen shot 2010-10-24 at 6.41.05 PM.webp
    Screen shot 2010-10-24 at 6.41.05 PM.webp
    13.1 KB · Views: 117
  • Screen shot 2010-10-24 at 6.41.18 PM.webp
    Screen shot 2010-10-24 at 6.41.18 PM.webp
    11.8 KB · Views: 115
  • Screen shot 2010-10-24 at 6.41.23 PM.webp
    Screen shot 2010-10-24 at 6.41.23 PM.webp
    11.7 KB · Views: 138
  • Screen shot 2010-10-24 at 6.41.45 PM.webp
    Screen shot 2010-10-24 at 6.41.45 PM.webp
    32.5 KB · Views: 141
  1. Usage
    To use Shorten_URL, make sure that the library class file is loaded (it is in /library/Shorten/URL.php) and verify that the class is installed and activated. If it is, it's as simple as calling the following line of PHP from you're code:
    PHP:
    Shorten_URL::shorten($url, $method);
    shorten() takes three parameters: The Long URL, the method, and a time out parameter. The last two are optional and may be omitted to be substituted for default values.
    Supported Methods:
    • Awe.sm: Method name -> awesm
    • Bit.ly: Method name -> bitly
    • Cli.gs: Method name -> cligs
    • Goo.gl: Method name-> googl
    • Is.gd: Method name -> isgd
    • No Shortening: Method name -> none
    • Simple Shortening (removing of titles): Method name -> simple
    • TinyURL: Method Name -> tinyurl
    • Ur.ly: Method Name -> urly
  2. Installing New Methods
    New methods are trivial to install, and all they require is a file with the method name in /library/Shorten/URL/. This file must have at least 3 methods:
    shorten($url, $timeout = 10)
    - Follows the naming pattern and is called by the Shorten_URL class. Must return 1 of three things:
    -- The Short URL
    -- False if it fails
    -- An array for errors: array('error' => 1, 'text' => 'errorText')
    options()
    - Must return an array of options. Used by Shorten_URL::install(). (See a bit.ly for an example.)
    about()
    - Returns an array of relevant information. (See bit.ly for an example.)
  3. Writing a Proper Options Function
    This function will be used to install required options for the specific service if it isn't already installed. The following options are available (see Bit.ly for an example on these):
    • type - required, must correspond to a valid option type in XenForo
    • default - optional, sets to '' if not set, and is the default option value
    • parameters - optional, set to '' and is parameters for certain types, ie select boxes.
    • label - required, the title of the option.
    • description - optional, set to '' and is the option description.
    Those options above are in an array that is the value of a key. The key is used to set the option ID, which has the form of suMethod_methodName_Key.
  4. Misc.
    • Any method you create is responsible for checking settings before using them. Shorten_URL:: doesn't account for that.
    • All details in about() are required. See any included function for a complete list.
    • Not all methods are installed / available. Run Shorten_URL::availableMethods() to retrieve a list of methods available to your add on for use. We suggest all add ons utilize this rather than an array / list of methods generated another way.
    • Shorten_URL does not handle errors within the shortening of the URL. A future version may handle fail handling (attempting another service, etc.), but until then, please look for the error / false returns.
    • Installing methods is up to the user, and so is uninstalling them. We request that you're add on does not force a user to install a specific method. Your add-on should be able to handle using the class without a specific method.
    • Users have the ability to turn off URL shortening as a whole, and you're add-on should respect this, by checking the value of suEnabled. If you still require 'shortening', you may call Shorten_URL::shorten($url, 'none'); and you will receive the same URL you passed it back.
    • You may see if a specific method is installed, by checking Shorten_URL::isInstalled($method); This should, in theory, not be used by an add-on, but may have some uses for some.
    • Shorten_URL will not allow a user (and / or add-on) to uninstall the default method.
    • Shorten_URL::getMethodList() will return a list of all methods found in the file system, but this list of methods may not be available and / or installed: use Shorten_URL::availableMethods(); in your add-ons.
  5. Submitting new Methods
    Cezz and I want this to be a community effort to create a standardized, supported, method of shortening URLs in add ons that require them. If you create a method, feel free to add them as an attachment here and specifically post permission to include in the add on.
 
Add-ons that utilize and or require Shorten URL services:

None (yet)! Want yours listed? Send me a PC or leave a comment on how you are using it!
 
Can you use your account for say bit.ly and get the statistics for the links?

Bit.ly requires the API key attached to your account. However, we don't have the bit ly statistics support. However, anyone in theory could write an add-on that utilizes this and just implements statistics getting. :) It may make it into a future version.
 
This looks like a pretty handy little plugin. It's definitely make sharing links much easier on sites liek Twitter. Thanks, King Kovifor!
 
Could we see a demonstration or screenshots? It looks interesting.

The are coming soon. We mad a few changes from the previous screenshots that we had. I'll get them up with v1.0.1 which will be released soon. And projectego, right now, you cannot share anything with Twitter or any other service. It requires a developer to build that.
 
Updated to v1.0.1 with updates to the kwn.me method (as well as the 'removal' of the quicklink.me method) as per request from Mikey & Floris. Also, updated with some demo screenshots.
 
I will put it down as a suggested site, but feel free to write you're own class to accomplish it. :)
 
I might not have understood what this does. I installed it and I expecting automatically generated short address link for each thread or do we have to manually create the short urls (in which case the addon would be pointless). Could someone explain in noobs lamguage? :D
 
I might not have understood what this does. I installed it and I expecting automatically generated short address link for each thread or do we have to manually create the short urls (in which case the addon would be pointless). Could someone explain in noobs lamguage? :D
IMHO ATM it's useless for "normal users"
3rd party developers can use this for there add-ons (for example send threads to twitter,...)
 
IMHO ATM it's useless for "normal users"
3rd party developers can use this for there add-ons (for example send threads to twitter,...)

Right now, it is. Its released for developers, but once add-ons start to use this, users will get a benefit.
 
Top Bottom