-
-
Save ephsmith/becad6029db89476ae3f93f0d6ae9e43 to your computer and use it in GitHub Desktop.
Tiny URL API
This file contains hidden or 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 | |
function tiny_url($url) { | |
return file_get_contents('http://tinyurl.com/api-create.php?url=' . $url); | |
} | |
$json = json_decode(file_get_contents('php://input')); | |
echo tiny_url($json->url); | |
/* basic jQuery usage: | |
$.post('https://foo.bar/tiny-url-api.php', JSON.stringify({url: url_2b_shortened})) | |
.done(function(shortened) { | |
some_local_var = shortened; }); | |
*/ | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment