使用JavaScript创建Firebase动态链接

时间:2018-06-14 22:29:10

标签: javascript jquery ajax firebase firebase-dynamic-links

# graph all plots
if isinstance(yVar, str):
    try:
        if yVar in [col for col in boolDf.columns]:
            boolDf.plot('Date / Time', yVar, figsize=(12,3));
        else:
            numericalDf.plot('Date / Time', yVar, figsize=(12,3));
    except:
        print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
        print('There is no data for ' + yVar + ' during this time period')
else:
    for y in yVar:
       print(y)
       try:
           if y in [col for col in boolDf.columns]:
                boolDf.plot('Date / Time', y, figsize=(12,3));
           else:
               numericalDf.plot('Date / Time', y, figsize=(12,3));
       except:
           print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
           print('There is no data for ' + y + ' during this time period')

以上代码适用于"后缀"从请求中删除。这使得#34; UNGUESSABLE"网址,但我想要一个简短的网址。正如在https://firebase.google.com/docs/dynamic-links/rest?authuser=0的文档中所述,我添加了后缀选项参数,但结果为400响应。有什么想法吗?

1 个答案:

答案 0 :(得分:2)

我还没试过这个,但是......

POST 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");
    }
});