Short URL API
If you need short URL service integration with your site - this service provides API which works with GET and POST methods.
Simplest method is GET: all you need is to send query string with URL encoded like
http://itshrunk.com/?module=ShortURL&file=Add&url=http%3A%2F%2Fbrowsei.com%2FPictures%2F%3Fshow%3Dnew
or http://itshrunk.com/?module=ShortURL&file=Add&mode=API&url=http://link-to-short.com/here/
As answer you'll have plain text string/s with shorten URL - something like
http://itshrunk.com/3f84cb
GET variables allowed:
go - either "twitter" or "pownce" - redirects user to post forms on Twitter.com or Pownce.com with new short link filled in forms automatically.
Also you can use POST method with link http://itshrunk.com/?module=ShortURL&file=Add&mode=API
POST variables:
url - single URL submission
tag - custom tag to use with URL/s (note: if tag is taken - you'll have error message instead of new address)
pass - password (numbers and english letters allowed - but no special symbols)
validTill - link expiration date - format is 2008-12-05 (YYYY-MM-DD = year-month-day)
bulk - bulk URLs (start each from new line)
SAMPLE PHP SCRIPT - CURL must be enabled on your server for this sample to work.
EDIT the "BLUE" text below to your PHP page and you can also edit the CSS style to fit your site.
<?
if(isset($_GET['url']))
{
die(get_itshrunk_url(urldecode($_GET['url'])));
}
//gets the data from a URL
function get_itshrunk_url($url)
{
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,'http://itshrunk.com/?module=ShortURL&file=Add&mode=API&url='.$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
?>
<script type="text/javascript" src="http://itshrunk.com/moo1.2.js"></script>
<script>
window.addEvent('domready',function() {
var itshrunkURL = new Class({
//implements
Implements: [Options],
//options
options: {
checkURL: ''
},
//initialization
initialize: function(options) {
//set options
this.setOptions(options);
},
//a method that does whatever you want
createURL: function(url,complete) {
var req = new Request({
url: this.options.checkURL + '?url=' + url,
method: 'get',
async: false,
onComplete: function(response) { complete(response); }
}).send();
}
});
// -----EDIT checkURL VALUE to your php page---- //
var new_itshrunk_url = new itshrunkURL({
checkURL: 'YOUR_PHP_PAGE.php'
});
$('geturl').addEvent('click',function() {
if($('url').value) {
var newu = new_itshrunk_url.createURL($('url').value,function(resp) {
$('newurl').set('html','Your URL is <a href="' + resp + '" target="_blank">' + resp + '</a> Try it!');
});
}
});
});
</script>
<style>
div.itshrunk {
margin:10px;
text-decoration: none;
border: 3px solid #c0c0c0;
width: 300px;
height: 90px;
padding-top:0px;
padding-bottom:0px;
padding-right:0px;
padding-left:0px;
overflow: invisible;
clear: both;
background-color:#FFF;
color: #111111;
-moz-border-radius: 10px;
-o-border-radius: 10px;
-webkit-border-radius: 10px;
-khtml-border-radius: 10px;
border-radius: 10px;
}
div.itlogo {
float: left;
padding-top:5px;
padding-bottom:5px;
}
div.itinput {
float: left;
padding-left:5px;
font-family: Verdana, Geneva, sans-serif;
font-size: 12px;
font-style: normal;
font-weight: bold;
text-decoration: none;
color: #FFF;
}
div.itbutton {
float: left;
font-family: Verdana, Geneva, sans-serif;
font-size: 10px;
font-style: normal;
font-weight: bold;
text-decoration: none;
}
div.itreturn {
float: left;
font-family: Verdana, Geneva, sans-serif;
font-size: 10px;
font-style: normal;
font-weight: bold;
padding-left:5px;
text-decoration: none;
color: #666;
}
</style>
<div class="itshrunk">
<form method="post" action="http://itshrunk.com/?module=ShortURL&file=Add&mode=API">
<div class="itlogo"><a href=http://itshrunk.com target=_blank><img border="0" src="smlogo.png"></a></div>
<div class="itinput"><input type="text" id="url" size="30" value="http://" /></div>
<div class="itbutton"><input type="button" id="geturl" value="Shrink it!" /></div>
<div id="newurl" class="itreturn"></div>
</form></div>
