Skip to content

Instantly share code, notes, and snippets.

@takuya
Last active Feb 17, 2019
Embed
What would you like to do?
(function(long_url,callback){
bi = new URL("https://api-ssl.bitly.com/v3/shorten?");
var params = [
"login=YOUR_USER_ID",
"domain=j.mp",
"apiKey=YOUR_API_KEY",
"longUrl="+ encodeURIComponent(long_url)
]
bi.search = "?"+params.join('&')
var xhr = new XMLHttpRequest();
xhr.onreadystatechange=function () {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
var res = JSON.parse(xhr.responseText);
callback(res["data"]["url"])
} else {
alert('There was a problem with the request.');
}
}
}
xhr.open("GET",bi.toString());
xhr.send(null)
})(location.href,function(a){prompt("", a);})
@takuya

This comment has been minimized.

Copy link
Owner Author

@takuya takuya commented Jan 28, 2015

httpsに変えた

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment