My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
API  
Application Programming Interface
Updated Jul 14, 2008 by vermaabh...@gmail.com

Introduction

Use Compress URL from your own application by using the PHP or the javascript APIs included since version 1.1 .

PHP

Just pass the following GET parameters to api.php :

  • url : The URL you want to compress
  • tiny : The shortened version you want
  • check : If you only want to check the availability and not compress it.

Examples

http://cyb3r.in/api.php : Gives the usage

http://cyb3r.in/api.php?url=http://www.google.com : gives the corresponding compressed version

http://cyb3r.in/api.php?tiny=g : gives the corresponding uncompressed version

http://cyb3r.in/api.php?url=http://www.google.com&tiny=goog&check : checks availability

http://cyb3r.in/api.php?url=http://www.google.com&tiny=go : tries to compress

Javascript

Include the javascript "api.js" and call the function API_compress_url( queryString, callback_function_name);

queryString should contain the GET variables. callback_function_name is the name of the function that takes one string argument.

The function is called when the compression is done. The string argument contains the output.

Example

A working example is included in the version 1.1 release and also set up here.

<!-- Include the javascript API -->
<script language="javascript" type="text/javascript" src="api.js"> </script>

<!-- Start of your own Javascript -->
<script language="javascript" type="text/javascript">
function compress() {
	// Get the "url" and "tiny" from the input boxes
	var url = document.getElementById("url").value;
	var tiny = document.getElementById("tiny").value;
	
	// Get checked value from checkbox
	if(document.getElementById("check").checked) 
		check = "&check";
	else
		check = "";
		
	// Call api : API_compress_url( queryString, callback_function_name)
	API_compress_url("url="+url + "&tiny=" + tiny + check, "call_me_when_done");
}

function call_me_when_done(tinyedUrl) {
	// Just alert whatever is returned
	alert(tinyedUrl);
}
</script>

Sign in to add a comment
Powered by Google Project Hosting