bitly ã®api ãv4ã«ãªã£ãã®ã§å¯¾å¿ããã
v3ã¯çµæ§æ°ã«å ¥ã£ã¦ã¦ãURLã«ãã¼ãå«ããããããGETãªã¯ã¨ã¹ãã§ãåããããã¢ãã¬ã¹ãã¼ããç縮ã§ãã¦ä¾¿å©ã ã£ããã§ããããã
APIããããPOST/BEARERã«ãªã£ã¦ãã¾ã£ãã®ã§ãå°ã ã¤ãããã®ããããã¨ã¯ããããµã¯ãã¨ä½¿ãããããã®ã§ããã¯ãã¼ã¯ã¬ãããä½æãç´ãã
let bitly=(async (long_url) =>{ const BITLY_ACCESS_TOKEN = "xxxxxxxxxxxxxxxxxxxxxxxx"; const url = 'https://api-ssl.bitly.com/v4/shorten'; let ret = await (await fetch( url, { headers: { "Content-Type": "application/json", "Authorization": `Bearer ${BITLY_ACCESS_TOKEN}` }, method:'post', body: JSON.stringify({ "long_url": long_url }) } )).json() console.log(ret.link) await prompt("", ret.link) location.href=ret.link }) bitly((typeof url_for_bitly != 'undefined') ? url_for_bitly : location.href)
ã¢ãã¬ã¹ãã¼ãããæ¤ç´¢ã·ã§ã¼ãã«ããã§ä½¿ããªãã®ã¯ãã¡ãã£ã¨å°ããã§ãããããVivalidiãªããªãã¨ããªãããã ãã©ã
ãã°ããã¯ãããã¯ãã¼ã¯ã¬ãããããããã¯ãã¼ã¯ãã使ãã¾ãã