首页 > 解决方案 > 需要 amp-ad-custom 用法说明和示例代码

问题描述

我正在与我的特殊客户一起创建我的自定义广告服务器。我在阅读、阅读、阅读……不理解 amp.dev 网站上的这份文档 --> https://amp.dev/documentation/components/amp-ad-custom/

我的网站https://example.site完全有效且有效,我的广告网站https://ads.site完全有效且有效,

https://example.site/ex-page.html内容:

<!DOCTYPE html>
<html ⚡ lang="tr">
<head>... 
BLA BLABLA other contents..
</head>
<body>
<amp-ad-custom width="320" height="250" src="https://ads.site/ex-ads.html"></amp-ad-custom>
</body>
</html>

https://ads.site/ex-ads.html内容:

<? header("Access-Control-Allow-Origin: https://example.site");
header("Access-Control-Allow-Credentials: true");
header("AMP-Ad-Template-Extension: amp-mustache");
header("Amp-Ad-Response-Type: template");?>
<!DOCTYPE html>
<html ⚡4ads>
<head>... 
BLA BLABLA other contents..
</head>
<body>
<amp-img src="https://ads.site/image/pizza.png" width="300" height="250" layout="fixed" alt="pizza"></amp-img>
</body>
</html>

我做的标签关联过程是否有错误?放大器验证所有页面都正常。

我们将在哪里使用 amp-ad-custom 文档中提到的广告服务器标题下的 JSON 文本?

广告服务器

广告网络需要提供一个新的服务端点,该端点以 JSON 格式返回 CORS 响应:

{
  templateUrl: "https://adexample.com/amp_template_1.html",
  data: {
    clickUrl: "https://buy.com/buy-1",
    buttonText: "Buy now"
  },
  analytics: {
    type: "googleanalytics",
    config: {
      ...
    }
  }
}

我尝试了不同的方法。在所有尝试之后,amp-ad-custom 标签的位置是空的。页面上不显示任何内容。错误控制台中只有 1 个错误。

无效的恢复模式!................ 错误.js:208

我在互联网上的任何地方都找不到更多信息和组件示例。是否可以编写带有示例链接和文件内容的示例?

标签: amp-htmlamp-ad

解决方案


推荐阅读