[英]Firebase dynamic links REST API returns 400 bad request
我正在嘗試使用由REST API
提供的 REST API 在node
中為我的移動應用程序創建動態鏈接。
我已按照這些說明進行操作
我正在使用axios
發送我的帖子請求這是我的代碼:
...
const link = await axios({
method: 'post',
url: 'https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=myApikey',
headers: {
'Content-Type' : 'application/json',
},
data: {
domainUriPrefix: 'https://threadsapp.page.link',
link: `https://threads-1511.web.app/threads/${tweet.id_str}`,
iosInfo: {
iosBundleId: 'com.bundleId',
iosAppStoreId: '1512677811',
iosIpadBundleId: 'com.bundleId',
},
androidInfo: {
androidPackageName: 'com.bundleId',
},
socialMetaTagInfo: {
socialTitle: `A thread by ${tweet.user.name}`,
socialDescription: `${tweet.full_text}`,
socialImageLink: 'https://firebasestorage.googleapis.com/v0/b/threads-1511.appspot.com/o/playstore.png?alt=media&token=896f4fe6-2882-442e-b15c-3767d61b8a70',
},
suffix: {
option: 'SHORT',
},
}
});
...
這是response
:
response: {
status: 400,
statusText: 'Bad Request',
headers: {
vary: 'X-Origin, Referer, Origin,Accept-Encoding',
'content-type': 'application/json; charset=UTF-8',
date: 'Wed, 03 Jun 2020 10:16:24 GMT',
server: 'ESF',
'cache-control': 'private',
'x-xss-protection': '0',
'x-frame-options': 'SAMEORIGIN',
'x-content-type-options': 'nosniff',
'alt-svc': 'h3-27=":443"; ma=2592000,h3-25=":443"; ma=2592000,h3-T050=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q049=":443"; ma=2592000,h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"',
'accept-ranges': 'none',
connection: 'close',
'transfer-encoding': 'chunked'
},
我所有的鏈接都使用文檔中提到的https://
或http://
方案:
提供的深度鏈接值至少必須以 http:// 或 https:// 方案開頭。 它還必須與控制台中輸入的任何 URL 模式白名單匹配。 否則,創建 API 將失敗,並出現 HTTP 錯誤代碼 400。
即使這樣我也收到此錯誤,我們將非常感謝您的幫助。
好像你錯過了"dynamicLinkInfo": {
部分,它在數據中應該看起來有點像這樣
const link = await axios({
method: 'post',
url: 'https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=myApikey',
headers: {
'Content-Type' : 'application/json',
},
data: {
dynamicLinkInfo: {
domainUriPrefix: 'https://threadsapp.page.link',
link: `https://threads-1511.web.app/threads/${tweet.id_str}`,
iosInfo: {
iosBundleId: 'com.bundleId',
iosAppStoreId: '1512677811',
iosIpadBundleId: 'com.bundleId',
},
androidInfo: {
androidPackageName: 'com.bundleId',
},
socialMetaTagInfo: {
socialTitle: `A thread by ${tweet.user.name}`,
socialDescription: `${tweet.full_text}`,
socialImageLink: 'https://firebasestorage.googleapis.com/v0/b/threads-1511.appspot.com/o/playstore.png?alt=media&token=896f4fe6-2882-442e-b15c-3767d61b8a70',
}
},
suffix: {
option: 'SHORT',
},
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.