Welcome Guest, Not a member yet? Register   Sign In
[updated] Shortify: A URL shortener plugin for CI
#1

[eluser]Yorick Peterse[/eluser]
As I couldn't find any plugins that would shorten an URL I thought it would be a nice idea to make one myself and share it with the rest of the CI community.
The plugin uses the API's of external services, such as TinyURL, to shorten the URL.

Services currently supported
* TinyURL
* Is.gd
* Tr.im
* U.nu

I am aware that there are some other known URL shorteners, such as Bit.ly, but those require you to log in and use an API key which I, for the sake of simplicity, am not going to support myself. However, feel free to add them yourself if needed, the plugin is licensed under the MIT license.

How to use
1. Unzip the archive and copy "shortify_pi.php" into either your system/plugins folder or your system/application/plugins folder.

2. Add the following line of code into your controller in one of your functions. It should also work in the view files but I haven't tested that yet.

Code:
<?php
//Load the Shortify plugin
$this->load->plugin('shortifyurl');
?>

3. Use the plugin by adding the shortify() function. The function works as following:

Code:
<?php
shortify('long_url','service',html_hyperlink);
?>

A screenshot with an example can be seen here: http://i41.tinypic.com/8zqukw.jpg

Examples

Code:
<?php
function foo() {
   echo shortify('http://www.yorickpeterse.com/','is.gd');  //This will output the following: http://is.gd/wbev
}
?>

Extra information

1. Each function will return the result, so don't forget to use the echo statment.
2. By default the third parameter will be set to false, if set to true the shortify() function will return the URL as an HTML hyperlink using the following format:

Code:
<a href="[short-url]" title="Shorter URL using [service-name]">[short-url]</a>

For example:

Code:
<a href="http://is.gd/2" title="Shorter URL using is.gd">http://is.gd/2</a>

Download

Shortify can be downloaded at the following URL: http://www.yorickpeterse.com/downloads/C...y_v1.0.zip
#2

[eluser]Yorick Peterse[/eluser]
Please note that I will clean up the source code tomorrow. This will reduce 4 seperate functions to 1 global functions.

e.g.

Code:
&lt;?php
//function shortify_url($url,$service);
echo shortify_url('http://www.yorickpeterse.com/','tinyurl');
?&gt;
#3

[eluser]Yorick Peterse[/eluser]
Updated the plugin to version 1.0. Merged the seperate functions into one big function called shortify().
#4

[eluser]Yorick Peterse[/eluser]
And Shortify now has its own Wiki page: http://codeigniter.com/wiki/Shortify_Plugin/
#5

[eluser]KuLi[/eluser]
Sorry but Error 404 by the Download
#6

[eluser]Yorick Peterse[/eluser]
[quote author="KuLi" date="1252344497"]Sorry but Error 404 by the Download[/quote]

I removed it since I no longer work on it.
#7

[eluser]KuLi[/eluser]
Can U publish the Code?
#8

[eluser]vevmesteren[/eluser]
I second that...
#9

[eluser]Yorick Peterse[/eluser]
Plugin can be downloaden from the following location: http://uploadrobots.com/NHkT6m
#10

[eluser]vevmesteren[/eluser]
very much appreciated! Thank you!
I am looking to integrate it into the ci_twitter and ci_facebook libraries. Will post them back here once completed...

V




Theme © iAndrew 2016 - Forum software by © MyBB