[soon] ShortURL Helper Library

Status
Not open for further replies.

Cezz

OMG Member
Joined
Sep 24, 2010
Messages
581
I am starting this discussion as a split from http://xenfans.com/threads/soon-xentweet-auto-tweet-threads.119/ more specifically about the helper library now.

This has been a joint effort between both KingKovifor and myself and we believe the library is almost ready to be released as a first alpha.

So what does this do / What is it?
This is a Helper library, on its own it wont to much but it will mean that shortURL settings can be set once and then all the other modification can then use the library, making it easier for other mod authors to shorten URLs.

How would a mod author use it?
To actually call the default shorten URL method is as simple as.

PHP:
Shorten_URL::shorten($url);

This will either return the URL or false.

More complex structure and allowing you to select the method you want can be formatted with two extra variables $method and $timeout.

EG.
PHP:
Shorten_URL::shorten('http://xenfans.com/','bitly');

Will do a number of checks, first it will make sure that bitly method exists if it does then it will load Shorten_URL_bitly::shorten($url), this will then return the URL or false, if the method doesn't exist it will return false.

We recommend that you use Shorten_URL::check($method); if you get a false return from a customized method.

So for example

PHP:
private function bitly($url)
{
      $shortURL = Shorten_URL::shorten($url,'bitly'); //shorten using bitly method
      if($shortURL != false) return $shortURL; // if it was successful then just return the URL
      if(Shorten_URL::check('bitly') == false) return = Shorten_URL::shorten($url); //bitly doesn't exist try using the default method
      return false; //short URL failed
}

Is there more?
Yes there is a lot more to this including a simple way to add new methods and also install required options E.G. to request API Key's Username's Etc.

We will keep this thread updated until the mod is released.
 

Floris

I'm just me :) Hi.
Staff member
Joined
Jan 1, 2001
Messages
60,100
Epic win! If you guys need me to code something in order to make it work with it smoother .. let me know.
 
Joined
Oct 6, 2010
Messages
105
Epic win! If you guys need me to code something in order to make it work with it smoother .. let me know.
I think its rather solid as is, but you can always code you're own shortening class (xenfo.ro, iirc) to prove just how simple it is to extend the system. :)
 
Joined
Oct 6, 2010
Messages
105
Uninstalling now has a check to verify that you do not attempt to uninstall the default URL shortening system (this is more for bit.ly, awe.sm, goo.gl, cli.gs than those that don't require options). If you do, you now get the following error message:
Screen shot 2010-10-19 at 4.34.09 PM.png

This system will support attempting to uninstall other, non-included methods as well, just as long as they are the default.

Also, the screenshot from Cezz's last post is a little bit outdated. It is now a much more robust and useful page / system. Here's an updated version:

shortURL-defaultList.png
 

Floris

I'm just me :) Hi.
Staff member
Joined
Jan 1, 2001
Messages
60,100
Maybe it's time you and I talked about how we can use my domain xenfo.ro for this as well :)
 
Joined
Oct 6, 2010
Messages
105
Its not included in XenForo (at least I don't see it in library/Zend/Services/ShortUrl), and ours is already coded and deeply integrated into XenForo.
 

ragtek

OMG Member
Joined
Jul 4, 2007
Messages
149
Its not included in XenForo (at least I don't see it in library/Zend/Services/ShortUrl), and ours is already coded and deeply integrated into XenForo.
That's why i wrote
copy the missing Files to the librabry/zend/service
, but i've seen now, that it's included in ZF 1.11(and i think xenforo uses 1.10)
 
Joined
Oct 6, 2010
Messages
105
That's why i wrote, but i've seen now, that it's included in ZF 1.11(and i think xenforo uses 1.10)
At this point in the game, it's not worth rewriting / abandoning to use Zend. The support 2 (IIRC) options. TinyURL and something else? We support 10 different methods (1 is no shortening) and can support advanced setup required services such as Bit.ly where you need an API key. You will be pleasantly surprised at how thought out and simple this system is (for developers too!).
 
Joined
Oct 6, 2010
Messages
105
And just to make things easier on the administrator, options are now no longer stored within the Options pane (well, they are, they are just hidden from view) and every option is completely contained within the page (per method).
 
Status
Not open for further replies.
Top