我如何为安培同意设置端点?

问题描述 投票:1回答:1

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

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

我知道checkConsentHref应该是我自己的网址,但是什么文件需要放在该位置,什么代码应该放在该位置?

<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位置有一些功能可以采取某种措施。

amp-html
1个回答
0
投票

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

可以通过checkConsentHref属性指定CORS端点。 amp-consent component将通过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代替“ own”是否是个好习惯。

© www.soinside.com 2019 - 2024. All rights reserved.