根据此文档,我想在我的动态链接中添加一些社交元标记信息:

https://firebase.google.com/docs/reference/dynamic-links/link-shortener

我必须在参数中添加socialMetaTagInfo。

但是,当我这样做时,出现以下错误消息400:


  消息:“接收到无效的JSON有效负载。未知名称
  “ socialMetaTagInfo”:找不到字段。“状态:” INVALID_ARGUMENT“


我的代码如下:

var params = {
        "longDynamicLink": "https://myapp.page.link/?link=https://www.google.com",
        "socialMetaTagInfo": {
          "socialTitle": "test title",
          "socialDescription": "test description"
        },
        "suffix": {
          "option": "SHORT"
        }
      }

      $.ajax({
          url: 'https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=MYAPIKEY',
          type: 'POST',
          data: JSON.stringify(params),
          dataType: 'json',
          contentType: 'application/json',
          success: function (response) {
              console.log(response.shortLink);
          },
          error: function () {
              console.log("error");
          }
        });
      });

最佳答案

var params = {
        "dynamicLinkInfo": "https://myapp.page.link",
        "link": "https://www.google.com",
        "socialMetaTagInfo": {
          "socialTitle": "test title",
          "socialDescription": "test description"
        },
        "suffix": {
          "option": "SHORT"
        }
      }

08-17 22:51