gpt4 book ai didi

javascript - 使用 JavaScript 创建 Firebase 动态链接

转载 作者:行者123 更新时间:2023-11-29 10:29:11 24 4
gpt4 key购买 nike

var object={
"longDynamicLink": "https://[APP_NAME].page.link/?link=[LINK_HERE]",
"suffix":{
"option":"SHORT"
}
}
$.ajax({
url: 'https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=[KEY_HERE]',
type: 'POST',
dataType: "json",
data: object,
success: function(response, textStatus, jqXHR) {
alert(response.shortLink);
},
error: function(jqXHR, textStatus, errorThrown){
alert(textStatus, errorThrown);
}
});

如果从请求中删除“后缀”,则上述代码有效。这会产生一个“UNGUESSABLE”网址,但我想要一个短网址。如 https://firebase.google.com/docs/dynamic-links/rest?authuser=0 处的文档所述我添加了后缀选项参数,但结果是 400 响应。有什么想法吗?

最佳答案

我还没有尝试过,但是......

发布https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=api_key

var params = {
"longDynamicLink": "https://example.page.link/?link=http://www.example.com/&apn=com.example.android&ibi=com.example.ios",
"suffix": {
"option": "SHORT"
}
}

$.ajax({
url: 'https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=[KEY_HERE]',
type: 'POST',
data: jQuery.param(params) ,
contentType: "application/json",
success: function (response) {
alert(response.status);
},
error: function () {
alert("error");
}
});

关于javascript - 使用 JavaScript 创建 Firebase 动态链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50866807/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com