Part of the EllisLab Network
   
1 of 2
1
[updated] Shortify: A URL shortener plugin for CI
Posted: 02 May 2009 04:35 PM   [ Ignore ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  640
Joined  05-02-2009

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.

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

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

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

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

Examples

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

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

For example:

<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/CI_Plugins/Shortify/Shortify_v1.0.zip

 Signature 

READ THE USERMANUAL BEFORE POSTING ON THE FORUM

Profile
 
 
Posted: 02 May 2009 05:47 PM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  640
Joined  05-02-2009

Please note that I will clean up the source code tomorrow. This will reduce 4 seperate functions to 1 global functions.

e.g.

<?php
//function shortify_url($url,$service);
echo shortify_url('http://www.yorickpeterse.com/','tinyurl');
?> 
 Signature 

READ THE USERMANUAL BEFORE POSTING ON THE FORUM

Profile
 
 
Posted: 03 May 2009 05:23 AM   [ Ignore ]   [ # 2 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  640
Joined  05-02-2009

Updated the plugin to version 1.0. Merged the seperate functions into one big function called shortify().

 Signature 

READ THE USERMANUAL BEFORE POSTING ON THE FORUM

Profile
 
 
Posted: 03 May 2009 02:38 PM   [ Ignore ]   [ # 3 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  640
Joined  05-02-2009

And Shortify now has its own Wiki page: http://codeigniter.com/wiki/Shortify_Plugin/

 Signature 

READ THE USERMANUAL BEFORE POSTING ON THE FORUM

Profile
 
 
Posted: 07 September 2009 07:28 AM   [ Ignore ]   [ # 4 ]  
Summer Student
Total Posts:  5
Joined  08-11-2009

Sorry but Error 404 by the Download

Profile
 
 
Posted: 07 September 2009 02:43 PM   [ Ignore ]   [ # 5 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  640
Joined  05-02-2009
KuLi - 07 September 2009 07:28 AM

Sorry but Error 404 by the Download

I removed it since I no longer work on it.

 Signature 

READ THE USERMANUAL BEFORE POSTING ON THE FORUM

Profile
 
 
Posted: 08 September 2009 12:44 PM   [ Ignore ]   [ # 6 ]  
Summer Student
Total Posts:  5
Joined  08-11-2009

Can U publish the Code?

Profile
 
 
Posted: 24 November 2009 04:41 PM   [ Ignore ]   [ # 7 ]  
Grad Student
Avatar
Rank
Total Posts:  32
Joined  08-29-2007

I second that…

 Signature 

vevmedia code-igniter things

Profile
 
 
Posted: 26 November 2009 08:12 AM   [ Ignore ]   [ # 8 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  640
Joined  05-02-2009

Plugin can be downloaden from the following location: http://uploadrobots.com/NHkT6m

 Signature 

READ THE USERMANUAL BEFORE POSTING ON THE FORUM

Profile
 
 
Posted: 26 November 2009 08:46 AM   [ Ignore ]   [ # 9 ]  
Grad Student
Avatar
Rank
Total Posts:  32
Joined  08-29-2007

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

 Signature 

vevmedia code-igniter things

Profile
 
 
Posted: 09 April 2010 08:43 AM   [ Ignore ]   [ # 10 ]  
Summer Student
Total Posts:  9
Joined  11-02-2009

http://uploadrobots.com/NHkT6m is not working anymore, can someone upload it again?

Profile
 
 
   
1 of 2
1
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 819, on March 11, 2010 11:15 AM
Total Registered Members: 149971 Total Logged-in Users: 39
Total Topics: 103610 Total Anonymous Users: 4
Total Replies: 518112 Total Guests: 455
Total Posts: 621722    
Members ( View Memberlist )