Skip to content

Instantly share code, notes, and snippets.

@kbrmedia
Created February 2, 2018 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kbrmedia/51aa5173ecd13598ae066e5176a0af9c to your computer and use it in GitHub Desktop.
Save kbrmedia/51aa5173ecd13598ae066e5176a0af9c to your computer and use it in GitHub Desktop.
Premium URL Shortener API PHP Request
<?php
// Using JSON Response
$api_url="http://yoursite.com/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"];
}
// Using Plain Text Response
$api_url="http://yoursite.com/api?api=APIKEY&url=THELONGURLTOBESHORTENED&custom=CUSTOMALIAS&format=text";
$res= @file_get_contents($api_url);
if($res){
echo $res;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment