首页 > 解决方案 > 谷歌的 ampUrls:batchGet 返回 404?

问题描述

我们在 2017 年左右构建了一个预定脚本,用于针对 Google 的 AMP 验证 API 测试一组 URI。

很久没有检查过脚本了,但最近我们的一位用户抱怨说,没有一个 URI 列出 AMP 等效项(我们使用 API 的原因是为了查找页面的 AMP 版本)。

现在,查看 Google 的文档并使用嵌入式测试面板测试我们的 JSON 有效负载,一切正常。

但是,当从我们的服务器对他们列出的 API 端点执行相同的数据时,我们会收到 404 错误。实际上,只需将 API 端点 URI 复制/粘贴到浏览器也会返回 404,这有点出乎意料。

是否有我们遗漏的东西,或者谷歌只是关闭了服务,没有在他们的文档页面上通知它,或者..?

我只是发布带有 URI 的基本 JSON 有效负载,我想检查它们是否有可用的 AMP 版本,例如:

{
"urls": [
"https://www.dailymail.co.uk/sport/football/article-6729017/Is-VAR-working-change-Reporters-analyse-video-technology-football.html?ns_mchannel=rss&ns_campaign=1490&ito=1490",
"https://www.talouselama.fi/uutiset/te/2223797c-6be5-3be1-b1aa-f774ff23d63e","https://www.theguardian.com/uk-news/2019/feb/21/teenager-shot-in-fight-on-london-tube-barking-hammersmith-and-city-line"
],
"lookupStrategy": "FETCH_LIVE_DOC"
}

至:

https://acceleratedmobilepageurl.googleapis.com/v1/ampUrls:batchGet

使用 POST,将服务密钥作为查询参数 (?key=xxx)。

我们得到的回报是 404。没有错误,没有 JSON 数据,只是普通的旧 HTML 格式的 404。

标签: google-apiamp-html

解决方案


服务很好,您的查询应该返回:

{
  "ampUrls": [
    {
      "originalUrl": "https://www.theguardian.com/uk-news/2019/feb/21/teenager-shot-in-fight-on-london-tube-barking-hammersmith-and-city-line",
      "ampUrl": "https://amp.theguardian.com/uk-news/2019/feb/21/teenager-shot-in-fight-on-london-tube-barking-hammersmith-and-city-line",
      "cdnAmpUrl": "https://amp-theguardian-com.cdn.ampproject.org/c/s/amp.theguardian.com/uk-news/2019/feb/21/teenager-shot-in-fight-on-london-tube-barking-hammersmith-and-city-line"
    },
    {
      "originalUrl": "https://www.dailymail.co.uk/sport/football/article-6729017/Is-VAR-working-change-Reporters-analyse-video-technology-football.html?ns_mchannel=rss&ns_campaign=1490&ito=1490",
      "ampUrl": "https://www.dailymail.co.uk/sport/football/article-6729017/amp/Is-VAR-working-change-Reporters-analyse-video-technology-football.html",
      "cdnAmpUrl": "https://www-dailymail-co-uk.cdn.ampproject.org/c/s/www.dailymail.co.uk/sport/football/article-6729017/amp/Is-VAR-working-change-Reporters-analyse-video-technology-football.html"
    }
  ],
  "urlErrors": [
    {
      "errorCode": "NO_AMP_URL",
      "errorMessage": "No AMP URL for the request URL.",
      "originalUrl": "https://www.talouselama.fi/uutiset/te/2223797c-6be5-3be1-b1aa-f774ff23d63e"
    }
  ]
}

推荐阅读