Facebook即时文章HTML发布错误

Facebook即时文章HTML发布错误,facebook,http,facebook-graph-api,post,facebook-instant-articles,Facebook,Http,Facebook Graph Api,Post,Facebook Instant Articles,我在api中发布HTML内容时遇到了一个拦截器。我能够成功地发布到端点,并收到一个状态ID作为响应。然后,当我在端点上使用GET检查状态时,错误消息会告诉我我的内容格式不正确。我可以在即时文章中手动在我的频道上发布完全相同的HTML内容,并且不会收到关于HTML格式的任何警告。我还尝试使用Facebook提供的示例文章HTML,它也会返回错误消息。任何建议都将不胜感激。以下是我的请求示例: POST /{my_page_id}/instant_articles?access_token={my_

我在api中发布HTML内容时遇到了一个拦截器。我能够成功地发布到端点,并收到一个状态ID作为响应。然后,当我在端点上使用GET检查状态时,错误消息会告诉我我的内容格式不正确。我可以在即时文章中手动在我的频道上发布完全相同的HTML内容,并且不会收到关于HTML格式的任何警告。我还尝试使用Facebook提供的示例文章HTML,它也会返回错误消息。任何建议都将不胜感激。以下是我的请求示例:

POST /{my_page_id}/instant_articles?access_token={my_access_token}&amp; html_source=<!DOCTYPE html><html lang="en" prefix="op: http://media.facebook.com/op HTTP/1.1
Host: graph.facebook.com
cache-control: no-cache
Postman-Token: {postman_token}
然后,我通过调用以下命令获取文章状态端点:

GET /{page_id}?access_token={my_access_token}&amp; fields=errors,html_source,instant_article,status HTTP/1.1
Host: graph.facebook.com
cache-control: no-cache
Postman-Token: {postman_token}

…我从该端点得到的响应如下:

{
    "errors": [
        {
            "level": "ERROR",
            "message": "AttValue: \" expected"
        },
        {
            "level": "ERROR",
            "message": "Couldn't find end of Start Tag html"
        },
        {
            "level": "ERROR",
            "message": "Missing Article's Canonical URL: There is no URL specified for this article. A canonical URL needs to be claimed and placed within the HTML to generate an Instant Article. Refer to URLs under Publishing Articles in the Instant Articles documentation for more information on claiming and inserting a canonical URL."
        }
    ],
    "html_source": "<!DOCTYPE html><html lang=\"en\" prefix=\"op: http://media.facebook.com/op",
    "status": "FAILED",
    "id": "2005563182874064"
}
{
“错误”:[
{
“级别”:“错误”,
“消息”:“AttValue:\”应为“预期”
},
{
“级别”:“错误”,
“消息”:“找不到开始标记html的结尾”
},
{
“级别”:“错误”,
“消息”:“缺少文章的规范URL:没有为此文章指定URL。需要声明规范URL并将其放置在HTML中以生成即时文章。有关声明和插入规范URL的详细信息,请参阅即时文章文档中“发布文章”下的URL。”
}
],

“html_source”:“您总是希望将有效负载数据放在POST请求的正文中,并作为GET的查询字符串。任何时候,API调用的数据对于URL来说都是极端的(不能超过2083个字符),这是一个关键指标,表明这可能不是一个GET。

您的答案解决了我的问题。我还意识到,我的HTML内容中有双引号,但没有正确转义。我将所有双引号替换为单引号,然后将我的内容放入docString中。完成此操作后,我收到了正确的成功响应.非常感谢你的帮助!
GET /{page_id}?access_token={my_access_token}&amp; fields=errors,html_source,instant_article,status HTTP/1.1
Host: graph.facebook.com
cache-control: no-cache
Postman-Token: {postman_token}

{
    "errors": [
        {
            "level": "ERROR",
            "message": "AttValue: \" expected"
        },
        {
            "level": "ERROR",
            "message": "Couldn't find end of Start Tag html"
        },
        {
            "level": "ERROR",
            "message": "Missing Article's Canonical URL: There is no URL specified for this article. A canonical URL needs to be claimed and placed within the HTML to generate an Instant Article. Refer to URLs under Publishing Articles in the Instant Articles documentation for more information on claiming and inserting a canonical URL."
        }
    ],
    "html_source": "<!DOCTYPE html><html lang=\"en\" prefix=\"op: http://media.facebook.com/op",
    "status": "FAILED",
    "id": "2005563182874064"
}