• 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?

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.

Developer
  • 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...

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

}[php]

If 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

PHP:
$shortURL = Shorten_URL::shorten($url,'bitly'); //shorten using bit.ly method

Though we do suggest you make some sanity checks IE

PHP:
Shorten_URL::check('bitly');

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

PHP:
Shorten_URL_bitly::about();

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.
 
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:
PHP:
Shorten_URL::getAvailableMethods();

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.
 
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:

http://xen1.8wayrun.com/media/soul-edge-blade-introduction-edge-of-soul.2/

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...
 
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:

http://xen1.8wayrun.com/media/soul-edge-blade-introduction-edge-of-soul.2/

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...
Twitter, SMS, and other things that have a limit.
 
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.
 
ZendFramework 1.11 released a URL shortener. http://framework.zend.com/manual/en/zend.service.short-url.html

When it gets updated it will be stock functionality, though you might still need a wrapper around it.

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.
 
Back
Top Bottom