Skip to content

Instantly share code, notes, and snippets.

@StephanStanisic
Last active March 27, 2016 11:03
Show Gist options
  • Save StephanStanisic/b7017b1a8cd3c785e332 to your computer and use it in GitHub Desktop.
Save StephanStanisic/b7017b1a8cd3c785e332 to your computer and use it in GitHub Desktop.
url shortener, open source, php and js
function short(urltoshort) {
// Our ajax request
var xmlhttp;
if (window.XMLHttpRequest) {
// Default browsers
xmlhttp = new XMLHttpRequest();
} else {
// Fallback for IE
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
// Do what you want with the url. Output example: http://88.site88.net/12345678
prompt("Your URL:", xmlhttp.responseText);
}
}
// And send it!
xmlhttp.open("GET","http://88.site88.net/index.html?urlmake=" + encodeURIComponent(urltoshort), true);
xmlhttp.send();
}
short("http://google.com");`

##THE BEST, MOST AWESOME, AND MOST EASY URL SHORTNER Just an ajax request to http://88.site88.net/?urlmake=[yea super long url]. Thats all. O, did I told you that you can use the site http://88.site88.net also for pesonal use? I have a nice GUI there.
###Usage: short("http://google.com"); wil give somting like http://88.site88.net/93363523
short("data:text/html,<h1>LOL</h1>"); wil give somting like http://88.site88.net/71624148

###Example: function short(urltoshort) {
// Our ajax request
var xmlhttp;
if (window.XMLHttpRequest) {
// Default browsers
xmlhttp = new XMLHttpRequest();
} else {
// Fallback for IE
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
// Do what you want with the url. Output example: http://88.site88.net/12345678
prompt("Your URL:", xmlhttp.responseText);
}
}
// And send it!
xmlhttp.open("GET","http://88.site88.net/index.html?urlmake=" + encodeURIComponent(urltoshort), true);
xmlhttp.send();
}
short("http://google.com");`

function short($url){
return file_get_contents("http://88.site88.net/index.html?urlmake=" . urlencode($url));
}
short("http://google.com");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment