gpt4 book ai didi

amp-html - 如何为 amp-consent 设置端点?

转载 作者:行者123 更新时间:2023-12-04 15:44:45 30 4
gpt4 key购买 nike

我不知道我需要在 checkConsentHref 的 URL 引用的文档中放置什么代码。

我使用了 https://amp.dev/documentation/examples/user-consent/basic_user_consent_flow/?format=websites 中的示例代码.

我知道 checkConsentHref 应该是我自己的 url,但是那个位置需要放什么文档,里面应该放什么代码?

<amp-consent layout="nodisplay" id="consent-element">
<script type="application/json">
{
"consents": {
"my-consent": {
"checkConsentHref": "https://example.com/api/show-consent",
"promptUI": "consent-ui"
}
}
}
</script>
</amp-consent>

我希望在 checkConsentHref 位置有一些功能来采取某种行动。

最佳答案

我在这里找到了很好的解释:About consent

可以通过 checkConsentHref 属性指定 CORS 端点。 amp-consent 组件 将通过 POST 请求检查是否需要显示同意 UI。对此请求的响应应如下所示:

{
"promptIfUnknown": true
}

#or

{
"promptIfUnknown": false
}


所以你可以在那里添加例如 https://ampbyexample.com/samples_templates/consent/getConsent第一次看到这个网址时,我以为它只是一个例子,但它确实有效。此 url 存储有关显示同意的信息。您可以在 JS 控制台中检查它。

https://ampbyexample.com/samples_templates/consent/getConsent 将返回 "promptIfUnknown": true"promptIfUnknown": false基于之前的用户操作

我不知道使用这个“示例”url 代替自己的 url 是否是一个好习惯。

关于amp-html - 如何为 amp-consent 设置端点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56399374/

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