Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Use the rebrandly API with custom slashtags (also old)
<!doctype html>
URL:
<input id="box">
Slashtag:
<input id="slashtag">
<button onclick="makelink(document.getElementById('box').value, document.getElementById('slashtag').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, slash) {
$.ajax({
url:
"https://api.rebrandly.com/v1/links/new?apikey=7e550388f4e34160842f6d638293814d&destination=" +
q +
"&slashtag=" +
slash +
"&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