Has the Url Shortener in Google Apps Script change

2019-08-03 05:06发布

问题:

I've been using this simple function to create shortened links in Google Apps Script. It's been working for the past few months but stopped working few days ago. Has there been a change?

  function getShortenedUrl(url){   

      var longUrl = UrlShortener.newUrl()
      .setLongUrl(url);

      var shortUrl = UrlShortener.Url.insert(longUrl);

      return shortUrl.getId();
}

回答1:

Yes. It has. I figured it out the hard way. Just make a small change for it to work

function getShortenedUrl(url){   

      var longUrl = UrlShortener.newUrl();
      longUrl.setLongUrl(url);

      var shortUrl = UrlShortener.Url.insert(longUrl);

      return shortUrl.getId();
}