Firebase Dynamic Links Short Links API

const yourDynamicLinkDomain = "###"; // Please set your dynamic link domain.

function getShortUrl_(longUrl) {

const url = "https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=" + apiKey;
const options = {
payload: JSON.stringify({
dynamicLinkInfo: {
dynamicLinkDomain: yourDynamicLinkDomain,
link: longUrl,
},
}),
contentType: "application/json",
};
const res = UrlFetchApp.fetch(url, options);
const { shortLink } = JSON.parse(res.getContentText());
return shortLink;
}

// Please run this function.
function main() {

// do something for retrieving the long URL in your actual script.
const longUrl = "###"; // It supposes that your long URL is put to longUrl.

const shortUrl = getShortUrl_(longUrl); // Here, the long URL is shortned. You can use this.

// If "options" is required to be used, please use this.
const options = {

};
const res = UrlFetchApp.fetch(shortUrl, options);

}

For More details about Create Dynamic Links with the REST API

https://firebase.google.com/docs/dynamic-links/rest


Deprecated: File Theme without comments.php is deprecated since version 3.0.0 with no alternative available. Please include a comments.php template in your theme. in /home/syrsocco/public_html/wp-includes/functions.php on line 6131

Leave a Reply

Your email address will not be published. Required fields are marked *