Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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