This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// No errors | |
{ | |
"error":0, | |
"short":"http:\/\/webz.cc\/DkZOb" | |
} | |
// An error has occurred | |
{ | |
"error":1, | |
"msg":"Please enter a valid URL" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Using JSON Response | |
$api_url="http://webz.cc/api?key=APIKEY&url=THELONGURLTOBESHORTENED&custom=CUSTOMALIAS"; | |
$res= @json_decode(file_get_contents($api_url),TRUE); | |
if($res["error"]){ | |
echo $res["msg"]; | |
}else{ | |
echo $res["short"]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define("SHORTENER_URL", "http://webz.cc"); | |
define("SHORTENER_KEY", "123456789"); | |
/**** Sample PHP Function ***/ | |
function shorten($url, $custom = "", $format = "json") { | |
$api_url = SHORTENER_KEY."/api/?key=".SHORTENER_KEY; | |
$api_url .= "&url=".urlencode(filter_var($url, FILTER_SANITIZE_URL)); | |
if(!empty($custom)){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GET http://webz.cc/api?key=APIKEY&url=THELONGURLTOBESHORTENED&custom=CUSTOMALIAS |