Shorten URL Services

Status
Not open for further replies.
Joined
Oct 6, 2010
Messages
105
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 its own method, set the domain to quicklink.me in kwn.me's settings. If you want it in its own method, save the quicklinkme.php file and upload with new files).
  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.
 

Attachments

  • Screen shot 2010-10-24 at 6.40.05 PM.png
    Screen shot 2010-10-24 at 6.40.05 PM.png
    80.8 KB · Views: 35
  • Screen shot 2010-10-24 at 6.40.19 PM.png
    Screen shot 2010-10-24 at 6.40.19 PM.png
    84.4 KB · Views: 26
  • Screen shot 2010-10-24 at 6.40.31 PM.png
    Screen shot 2010-10-24 at 6.40.31 PM.png
    68.3 KB · Views: 26
  • Screen shot 2010-10-24 at 6.40.45 PM.png
    Screen shot 2010-10-24 at 6.40.45 PM.png
    51.6 KB · Views: 19
  • Screen shot 2010-10-24 at 6.40.55 PM.png
    Screen shot 2010-10-24 at 6.40.55 PM.png
    85.6 KB · Views: 16
  • Screen shot 2010-10-24 at 6.41.05 PM.png
    Screen shot 2010-10-24 at 6.41.05 PM.png
    55.3 KB · Views: 15
  • Screen shot 2010-10-24 at 6.41.18 PM.png
    Screen shot 2010-10-24 at 6.41.18 PM.png
    53 KB · Views: 21
  • Screen shot 2010-10-24 at 6.41.23 PM.png
    Screen shot 2010-10-24 at 6.41.23 PM.png
    27.9 KB · Views: 23
  • Screen shot 2010-10-24 at 6.41.45 PM.png
    Screen shot 2010-10-24 at 6.41.45 PM.png
    80.7 KB · Views: 23
  • Shorten.zip
    22.1 KB · Views: 29
Joined
Oct 6, 2010
Messages
105
  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.
 
Joined
Oct 6, 2010
Messages
105
List of Add-ons using / requiring Shorten URL library:

None (yet)! Get yours listed here by leaving a comment or sending me a PC!
 

George G Halstead

OMG Member
Joined
Oct 24, 2010
Messages
436
beta 2 gets an error when trying to go to the settings page, just a bland description. It says to try again later.
 

George G Halstead

OMG Member
Joined
Oct 24, 2010
Messages
436
Here is the exact error.

Code:
call_user_func(Shorten_URL_.DS_Store::about) [<a href='function.call-user-func'>function.call-user-func</a>]: First argument is expected to be a valid callback
 
Joined
Oct 6, 2010
Messages
105
Here is the exact error.

Code:
call_user_func(Shorten_URL_.DS_Store::about) [<a href='function.call-user-func'>function.call-user-func</a>]: First argument is expected to be a valid callback

Ugh. That shouldn't happen. I really need to fix this, but you got a Mac OS X file in the download (unavoidable really) but to solve, allow your FTP client to see hidden files and delete the .DS_Store file.
 
Status
Not open for further replies.
Top