1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. 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

Discussion in 'Add-on Releases [Archive]' started by Jeremy, Oct 23, 2010.

  1. Jeremy

    Jeremy Well-Known Member

    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!


    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:
    - Updated Kwn.me to include an optional setting (kwn.me's URL parameter) after speaking with its owners: Mikey & Floris.

    Attached Files:

    Insy, Mikey, Jeffin and 4 others like this.
  2. Jeremy

    Jeremy Well-Known Member

    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:
      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')
      - Must return an array of options. Used by Shorten_URL::install(). (See a bit.ly for an example.)
      - 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.
    laztrix, Peggy and fattony69 like this.
  3. Jeremy

    Jeremy Well-Known Member

    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!
  4. fattony69

    fattony69 Well-Known Member

    Can you use your account for say bit.ly and get the statistics for the links?
  5. Jeremy

    Jeremy Well-Known Member

    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.
  6. projectego

    projectego Active Member

    This looks like a pretty handy little plugin. It's definitely make sharing links much easier on sites liek Twitter. Thanks, King Kovifor!
  7. Jeffin

    Jeffin Well-Known Member

    Could we see a demonstration or screenshots? It looks interesting.
  8. Floris

    Floris Guest

    Excellent stuff indeed
  9. Jeremy

    Jeremy Well-Known Member

    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.
  10. kkm323

    kkm323 Well-Known Member

  11. Jeremy

    Jeremy Well-Known Member

    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.
  12. Brian Chance

    Brian Chance Member

    I would like to see support for the YOURLS script, it has an api so it should be doable.
    dartho likes this.
  13. Jeremy

    Jeremy Well-Known Member

    Its on the books for the next release.
    Brian Chance and dartho like this.
  14. Could you use it with my www.fhs.im site ;).

    It has an API, and runs on Open URL Shortener by Rodirig Polo or something like that.

  15. Jeremy

    Jeremy Well-Known Member

    I will put it down as a suggested site, but feel free to write you're own class to accomplish it. :)
  16. Jeffin

    Jeffin Well-Known Member

    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
  17. ragtek

    ragtek Guest

    IMHO ATM it's useless for "normal users"
    3rd party developers can use this for there add-ons (for example send threads to twitter,...)
  18. dartho

    dartho Active Member

    Good thing we are site admins as opposed to normal users, or are admins now users like 40 is the new 30? :)
  19. Shamil

    Shamil Well-Known Member

  20. Jeremy

    Jeremy Well-Known Member

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

Share This Page