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.

Is your add-on going to shorten URL's?

Discussion in 'Development Tutorials [Archive]' started by Cezz, Oct 21, 2010.

  1. Cezz

    Cezz Well-Known Member

    If so don't do it quite yet.. as posted over at http://xenfans.com/threads/soon-shorturl-helper-library.144/ we will soon be releasing a Helper API for shortening URL's meaning you will not have to code your own functions into your addon's.

    We see a number of benefits for this to both the application developer and the end users.

    • No need to write your own classes/functions
    • Gives end user multiple choices for which shorten API to use.
    • Easy to add your one class if needs be and make it available to all.
    End User
    • Will only need to supply their API keys etc once instead of having to redefine them for every mod that shortens URL's.
    Using the Helper API is very straight forward... Firstly check if it is installed and enabled...

    if(!XenForo_Application::get('options')->suEnabled) {


    so then shortening your url is as simple as

    php]$shortURL Shorten_URL::shorten($url); //shorten using default method
    or you could get more complex and define a custom method E.G. bit.ly you can do

    $shortURL Shorten_URL::shorten($url,'bitly'); //shorten using bit.ly method
    Though we do suggest you make some sanity checks IE

    will tell you if there is such a method installed... and

    will give you some extra information about the method.. IE long name, descripton, version, author, and if it is #1 installed #2 available (I.E. all required options are entered).

    There is a little more we are planning to add to this but it should be released soon, what we could do with for now is a realistic idea on extra things you the devs want added to this and also an idea if you would use this in a future project.
    feldon30 and Blandt like this.
  2. Jeremy

    Jeremy Well-Known Member

    As Cezz started, the class also has methods to allow a new shortener to be installed easily via a well defined options() function. Users choose when to install these functions, and are available at will. The class also provides methods for you to find out which shorteners are available via a simple call in the class:
    This will give you all methods that are available and installed properly. If a method needs installing, the about() method mentioned above will called a custom function in the method class (Shorten_URL_method) and check to see if all options have necessary values.

    Some powerful features are planned, but hopefully, you can utilize this. As this is a somewhat of a community effort, you may write your own shorteners (as well as suggest them!) and have them included by default.
  3. Jaxel

    Jaxel Well-Known Member

    I don't quite understand why people love "Short URLs" so much... especially when XenForo has a built in seo slugging feature... think of it this way... if I wanted someone to go to this url:


    I could tell them: http://xen1.8wayrun.com/media/2/ which is a URL that I can remember off the top of my head...

    or I could tell them... someshorturl.com/randomletters that I can't remember off the top of my head...

    When someone wants to donate to me... i just use: http://www.8wayrun.com/donate
    much easier to remember, and people don't need to write it down...
    Vladislav Rastrusny likes this.
  4. Forsaken

    Forsaken Well-Known Member

    Twitter, SMS, and other things that have a limit.
  5. mjp

    mjp Well-Known Member

    It's the younger generation. Short attention spans. Long URLs offend their delicate sensibilities. (Did you know they type with their thumbs!)
    Vladislav Rastrusny likes this.
  6. ragtek

    ragtek Guest

    i hate shoren urls
    nobody knows where they really link to.
    for example: http://goo.gl/4stbu
    Vladislav Rastrusny likes this.
  7. Cezz

    Cezz Well-Known Member

    Short URL's don't have to be used for everything and in-fact shouldn't be used for everything. However when you need to send a link in a format where your chars are limited...

    http://bit.ly/beDsIq is shorter than http://xenforo.com/community/threads/6826 and much shorter than http://xenforo.com/community/threads/is-your-add-on-going-to-shorten-urls.6826

    No mater how you look at it... there is a benefit... Now when you can create links like http://bit.ly/xenforo-example it is easy to remember, and probably more so than http://xenforo.com/community/threads/6826 and still shorter.
    Jeremy likes this.
  8. Scott

    Scott Active Member

  9. Cezz

    Cezz Well-Known Member

    It has been out a while but currently only supports shortener's that don't require any authentication etc. The mod that was created for XenForo supports many types of shorteners including things like awe.sm and bit.ly which require API's.

    The options for the shortening services are included in the XF admin area so are easily configured, and the library we created allows for the site admin to set a single default method that all mods will then use, meaning they only have to change one setting for all the mods to update.
    Jeremy likes this.

Share This Page