Skip to content

Instantly share code, notes, and snippets.

@vincens2005
Created February 11, 2021 23:59
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 vincens2005/df7c8892045538001080cd766b817021 to your computer and use it in GitHub Desktop.
Save vincens2005/df7c8892045538001080cd766b817021 to your computer and use it in GitHub Desktop.
an exapmple of the rebrandly API ising jQuery (ancient)
<!doctype html>
<input id="box">
<button onclick="makelink(document.getElementById('box').value);">Make link</button>
<div id="output"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js">
</script>
<script>
var data;
function makelink(q) {
$.ajax({
url:
"https://api.rebrandly.com/v1/links/new?apikey=c86aea45fca044478278907479a396e9&destination=" +
q +
"&domain[fullName]=rebrand.ly",
success: function (rawdata) {
var rawstring = JSON.stringify(rawdata);
data = JSON.parse(rawstring);
document.getElementById("output").innerHTML =
"<a href='https://" +
data.shortUrl +
"' target='_blank'>" +
data.shortUrl +
"</a>";
},
});
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment