javascript - Firebase URL 缩短器与 jQuery Ajax Post?

标签 javascript jquery firebase firebase-dynamic-links

我是 Firebase 新手。我正在尝试使用动态链接。这就是我到目前为止所拥有的......

    var longUrl = 'https://example.com/' + window.location.hash;
    var APIkey  = 'My Web API Key Here';
    var url     = 'https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=' + APIkey;

    var data = {
        "longDynamicLink": "https://abc123.app.goo.gl/?link=" + longUrl,
        "suffix": {
            "option": "SHORT"
        }
    };

    var request = $.ajax({
        url: url,
        dataType: 'json',
        type: 'post',
        contentType: 'application/json',
        data: JSON.stringify(data),
        processData: false,
        success: function( data, textStatus, jQxhr ){
            console.log(data);
            console.log(textStatus);
            console.log(jQxhr);
        },
        error: function( jqXhr, textStatus, errorThrown ){
            console.log( errorThrown );
        }
    });

我收到了 400 错误...

code:400
message:"Your project has not configured Dynamic Links. [https://firebase.google.com/docs/dynamic-links/rest#before_you_begin]"
status:"INVALID_ARGUMENT"

未配置动态链接是什么意思? “abc123”只是一个占位符吗?

最佳答案

有同样的问题 - 这就是我从 firebase 团队得到的答案:

Take note that to be able to view your Dynamic Link domain you'll have to add an app first. If you're using Firebase Dynamic Link as a substitute to Google Shortener, you can create a sample application (dummy app) for your project to proceed creating a Firebase Dynamic Links. Just enter dummy values for the iOS bundle ID or Android package name (ex: “my.dummy.app”) to continue.

然后你将输入从中获得的ID(例如 https://dedfgu.app.goo.gl ) 而不是占位符 (abc123.app.goo.gl)。

祝你好运!

关于javascript - Firebase URL 缩短器与 jQuery Ajax Post?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47408591/

相关文章:

javascript - 使用 ES6 创建 HTML 元素

javascript - 如何通过响应式调整大小来重复 HTML 中的字符?

javascript - 如何从选择框中获取选定的值,并在 HTML 链接中使用它?

javascript - 将单独的 CSS 和 JS 文件包含到标题中,或者将所有代码包含在一个 CSS 和一个 JS 文件中?

ios - Swift 和 Firebase 项目在模拟器上运行在实际设备上出现错误

javascript - puppeteer - 如何提交表单

javascript - 我如何激活第二次兜风之旅

javascript - 有什么方法可以测量到目前为止通过 jQuery 加载了多少 JSON 文件?

firebase - 我在哪里可以在 Firebase 控制台中找到 Stackdriver?

java - Firebase数据库,查找现有值