SilverStripe URL Shortener¶
SilverStripe URL Shortener provides an API for providing short URLs for your SilverStripe website. Use the supplied shortener to create shorter URLs on your own domain, the supplied Bit.ly plugin with your Bit.ly API key or implement your own service.
This is currently a developer API and requires some knowledge of coding within the SilverStripe framework.
Requirements¶
SilverStripe 2.4+
Installation¶
- Extract to a folder in your SilverStripe installation directory.
- Run /dev/build?flush=1
Usage Overview¶
Shorten URLs with:
$shortURL = URLShortener::shorten($longURL);
Expand URLs with:
$longURL = URLShortener::expand($shortURL);
Create new services by implementing URLShortenerService
Set alternative URL Shorteners in your _config.php with
URLShortener::set_url_shortener('BitlyURLShortener');
A bit.ly URL shortener service is provided. Apply for an API key at http://bit.ly and add the following to your _config.php:
BitlyURLShortener::set_username_and_key('username', 'apikey');
URLShortener::set_url_shortener('BitlyURLShortener');