2

In some JavaScript web client code, I currently use the Google URL shortener via the client libraries. Since Google is shifting over to Firebase for "dynamic link management", I would like to change my code accordingly.

Below is what I have now for the old shortening method that Google is phasing out. I have been unable to determine if Google's client API for JavaScript even supports Firebase dynamic URL generation. Does it? If so, how should I change the code below?

To set things up:

function initializeGoogleAPIs()
  {
  console.log("Initializing Google APIs.");
  var apiKey = '<MY_API_KEY>';
  gapi.client.setApiKey(apiKey);
  }

To shorten a URL:

function shortenURL(url, responseAction)
  {
  gapi.client.load('urlshortener', 'v1', function()
    {
    var payload =
      {
      'resource':
        {
        'longUrl': url
        }
      }

    var request = gapi.client.urlshortener.url.insert(payload);
    request.then(responseAction, logReasonError);
    });
  }
rcauvin
  • 91
  • 5

0 Answers0