将自定义域与 Firebase 动态链接结合使用
Using custom domains with Firebase Dynamic Links
我编写了一个 Google Apps 脚本函数,它使用 Firebase 的动态链接缩短了 URL -
function fbURLShort() {
var data = {
"dynamicLinkInfo": {
"domainUriPrefix": "https://example.page.link",
"link": "https://example.com/lenghtlyURL?with=hooks&more=additions"
},
"suffix": {
"option": "SHORT"
}
};
var url = "https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=myAPIkey"
var options = {
'method': 'POST',
"contentType": "application/json",
'payload': JSON.stringify(data),
"muteHttpExceptions":true
};
var response = UrlFetchApp.fetch(url, options);
Logger.log(response)
var json = response.getContentText();
var data = JSON.parse(json);
var obj = data["shortLink"];
Logger.log(obj)
}
这在使用 example.page.link domainUriPrefix 时非常有效;但是,还有一种方法可以 Connect a custom domain,而且我也能够成功地做到这一点(该域将显示在 Firebase 的托管部分下)。
但是,当我将 example.page.link 替换为 customdomain.com 时,它会抛出以下错误 -
"error": {
"code": 400,
"message": "Your project does not own Dynamic Links domain: https://customdomain.com [https://firebase.google.com/docs/dynamic-links/rest#create_a_short_link_from_parameters]",
"status": "INVALID_ARGUMENT"
}
现在,我想做的是使用 said 自定义域作为基础 link 来缩短 URLs 而不是 .page.link(通过动态链接)。
我该怎么做?
目前无法为 Firebase 动态链接使用完整的自定义域。 page.link
下的自定义子域都是可用的。
也就是说,我们以前听过这个请求。所以如果你真的对它感兴趣,请file a feature request。
自 2019 年 11 月起,可以使用最多 10 个域、自定义域或 *.page.link 域....只要它们都共享相同的后缀:(
我编写了一个 Google Apps 脚本函数,它使用 Firebase 的动态链接缩短了 URL -
function fbURLShort() {
var data = {
"dynamicLinkInfo": {
"domainUriPrefix": "https://example.page.link",
"link": "https://example.com/lenghtlyURL?with=hooks&more=additions"
},
"suffix": {
"option": "SHORT"
}
};
var url = "https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=myAPIkey"
var options = {
'method': 'POST',
"contentType": "application/json",
'payload': JSON.stringify(data),
"muteHttpExceptions":true
};
var response = UrlFetchApp.fetch(url, options);
Logger.log(response)
var json = response.getContentText();
var data = JSON.parse(json);
var obj = data["shortLink"];
Logger.log(obj)
}
这在使用 example.page.link domainUriPrefix 时非常有效;但是,还有一种方法可以 Connect a custom domain,而且我也能够成功地做到这一点(该域将显示在 Firebase 的托管部分下)。
但是,当我将 example.page.link 替换为 customdomain.com 时,它会抛出以下错误 -
"error": {
"code": 400,
"message": "Your project does not own Dynamic Links domain: https://customdomain.com [https://firebase.google.com/docs/dynamic-links/rest#create_a_short_link_from_parameters]",
"status": "INVALID_ARGUMENT"
}
现在,我想做的是使用 said 自定义域作为基础 link 来缩短 URLs 而不是 .page.link(通过动态链接)。 我该怎么做?
目前无法为 Firebase 动态链接使用完整的自定义域。 page.link
下的自定义子域都是可用的。
也就是说,我们以前听过这个请求。所以如果你真的对它感兴趣,请file a feature request。
自 2019 年 11 月起,可以使用最多 10 个域、自定义域或 *.page.link 域....只要它们都共享相同的后缀:(