1

I use the following code to shorten my long url via bitly.

      longURL= "https://www.google.ca/search?rlz=1C1NHXL_enCA722CA722&ei=A9RVW8HsEc2q_QbAm5OwDw&q=how+to+shorten+twitter+links+javascript&oq=how+to+shorten+twitter+links+javascript&gs_l=psy-ab.3...293814.304006.0.304188.38.32.3.3.3.0.181.3062.24j7.31.0....0...1c.1.64.psy-ab..1.36.2982...0j0i131k1j0i10k1j0i22i30k1j33i160k1j33i21k1.0.zha4WFnNa_s";
    let apiInstructions = {
        "format": "json",
        "apiKey": TWITTER.apiKey,
        "login": TWITTER.login,
        "access_token": "xxxxxxxxxxxxxxxxxxxxxxx",
        "longURL": encodeURIComponent(longURL)
    }
        console.log(TWITTER.shortenUrl + apiInstructions);
        axios.get("http://api.bitly.com/v3/shorten?callback=?" + apiInstructions).then(
            function (response) {

            }
        ).catch(function (response) {

        });

When I run that I get the follwoing:

{"status_code":500,"status_txt":"MISSING_ARG_ACCESS_TOKEN","data":[]}

My dource to follow was the following link :

https://stackoverflow.com/questions/4760538/using-only-javascript-to-shrink-urls-using-the-bit-ly-api

I only added access_token since without it I was still getting the same error. I am totally stuck now. Any idea?

Hamed Minaee
  • 2,480
  • 4
  • 35
  • 63

0 Answers0