Created
February 11, 2021 23:59
-
-
Save vincens2005/df7c8892045538001080cd766b817021 to your computer and use it in GitHub Desktop.
an exapmple of the rebrandly API ising jQuery (ancient)
This file contains 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
<!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