Skip to content

Instantly share code, notes, and snippets.

@ephsmith
Forked from MikeRogers0/tiny-url-api.php
Created May 1, 2018 01:32
Show Gist options
  • Save ephsmith/becad6029db89476ae3f93f0d6ae9e43 to your computer and use it in GitHub Desktop.
Save ephsmith/becad6029db89476ae3f93f0d6ae9e43 to your computer and use it in GitHub Desktop.
Tiny URL API
<?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