0

我是苹果新闻平台的新手,我开始使用苹果新闻 api 来使用 REST 为苹果新闻创建文章。从那以后,我在 Apple News Publisher 上创建了一个频道,并且可以从那里创建文章。因此,为了使用苹果新闻 api,我从设置中创建了 api 密钥、频道 ID 和秘密。然后我使用 post man 遵循文档中给出的相同示例。但尽管所有正确的信息 POST 调用返回“code”:“WRONG_SIGNATURE”我无法找到它背后的实际原因

发布请求的标头是:

Authorization : HHMAC; key="xxxxxxxx-d9bf-xxxx-9fb6-64c8bb4b1496"; signature="lCOOG8yrEYny/PDaDlQ43eGtiByW5jsndfks+ff35xns="; date="2019-10-10T12:54:19Z"

Content-Type : multipart/form-data; boundary=535e329ca936f79a19ac9a251f7d48f7

Accept : application/json

Content-Type : application/json

Content-Disposition : form-data; filename=article.json; name=article.json







and body has : 


POST : /channels/xxxxxxxx-xxxx-xxxx-8d41-67919f759014/articles HTTP/1.1
Host : news-api.apple.com
--535e329ca936f79a19ac9a251f7d48f7

{
  "version": "1.0",
  "identifier": "Apple_Demo",
  "title": "Sample article for test",
  "language": "en",
  "layout": {
    "columns": 7,
    "width": 1024,
    "margin": 70,
    "gutter": 40
  },
  "subtitle": "this is the demo sample text by api!!",
  "metadata": {
    "excerpt": "Simple with Headline above Header Image",
    "thumbnailURL": "https://developer.apple.com/news-publisher/download/Apple-News-Example-Articles/images/Iceland01.jpg"
  },
  "documentStyle": {
    "backgroundColor": "#f6f6f6"
  },
  "components": [
    {
      "role": "title",
      "layout": "titleLayout",
      "text": "Headline Above Image",
      "textStyle": "titleStyle"
    },
    {
      "role": "intro",
      "layout": "introLayout",
      "text": "this is the sample text for demo",
      "textStyle": "introStyle"
    },
    {
      "role": "header",
      "layout": "headerImageLayout",
      "style": {
        "fill": {
          "type": "image",
          "URL": "https://developer.apple.com/news-publisher/download/Apple-News-Example-Articles/images/Iceland01.jpg",
          "fillMode": "cover",
          "verticalAlignment": "center"
        }
      }
    },
    {
      "role": "author",
      "layout": "authorLayout",
      "text": "Byline | Publisher | Date",
      "textStyle": "authorStyle"
    },
    {
      "role": "body",
      "text": "this is another sample text for demo \n\n",
      "layout": "bodyLayout",
      "textStyle": "bodyStyle"
    }
  ],
  "componentTextStyles": {
    "default-title": {
      "fontName": "HelveticaNeue-Thin",
      "fontSize": 36,
      "textColor": "#2F2F2F",
      "textAlignment": "center",
      "lineHeight": 44
    },
    "default-subtitle": {
      "fontName": "HelveticaNeue-Thin",
      "fontSize": 20,
      "textColor": "#2F2F2F",
      "textAlignment": "center",
      "lineHeight": 24
    },
    "titleStyle": {
      "textAlignment": "left",
      "fontName": "HelveticaNeue-Bold",
      "fontSize": 64,
      "lineHeight": 74,
      "textColor": "#000"
    },
    "introStyle": {
      "textAlignment": "left",
      "fontName": "HelveticaNeue-Medium",
      "fontSize": 24,
      "textColor": "#000"
    },
    "authorStyle": {
      "textAlignment": "left",
      "fontName": "HelveticaNeue-Bold",
      "fontSize": 16,
      "textColor": "#000"
    },
    "bodyStyle": {
      "textAlignment": "left",
      "fontName": "Georgia",
      "fontSize": 18,
      "lineHeight": 26,
      "textColor": "#000"
    }
  },
  "componentLayouts": {
    "headerImageLayout": {
      "columnStart": 0,
      "columnSpan": 7,
      "ignoreDocumentMargin": true,
      "minimumHeight": "40vh",
      "margin": {
        "top": 15,
        "bottom": 15
      }
    },
    "titleLayout": {
      "columnStart": 0,
      "columnSpan": 7,
      "margin": {
        "top": 50,
        "bottom": 10
      }
    },
    "introLayout": {
      "columnStart": 0,
      "columnSpan": 7,
      "margin": {
        "top": 15,
        "bottom": 15
      }
    },
    "authorLayout": {
      "columnStart": 0,
      "columnSpan": 7,
      "margin": {
        "top": 15,
        "bottom": 15
      }
    },
    "bodyLayout": {
      "columnStart": 0,
      "columnSpan": 5,
      "margin": {
        "top": 15,
        "bottom": 15
      }
    }
  }
}

POST请求后显示:

{
    "errors": [
        {
            "code": "DATE_NOT_RECENT"
        }
    ]
}

任何帮助将不胜感激!

4

0 回答 0