首页 > 解决方案 > 通过 api 添加带有 child_attachments 的 Facebook 帖子时出现“无法使用 URL”错误

问题描述

我要trying使用 api 和 child_attachments 参数在 facebook 上发帖,所以我可以在 1 个帖子中传递多个 url。在 facebook 调试器中,我像这样传递 json

{
  "message": "test debug",
  "child_attachments": [
    {
      "link": {
        "link": "https://google.com"
      }
    },
    {
      "link": {
        "link": "https://ft.com"
      }
    }
  ]
}

但我收到以下错误消息

 { "error": {
    "message": "Invalid parameter",
    "type": "OAuthException",
    "code": 100,
    "error_data": {
      "blame_field_specs": [
        [
          "child_attachments[0][link]"
        ]
      ]
    },
    "error_subcode": 2061006,
    "is_transient": false,
    "error_user_title": "URL Can't Be Used",
    "error_user_msg": "The URL you entered, \"https://google.com\" doesn't direct to a website. Please enter a valid URL and try again.",
    "fbtrace_id": "xxxxxxxx"
  }
}

我尝试在应用程序域中设置 url,我尝试使用带/不带 https 和带/不带 www 的 url。

仍然没有运气,有人可以给我一些建议吗?

谢谢,罗曼。

标签: phpfacebook

解决方案


好的,所以我想,正确的格式应该是这样的:

{
  "message": "message to post",
  "link": "https://yahoo.com",
  "child_attachments": [
    {
      "link": "https://yahoo.com",
      "name": "name -1",
      "picture": "https://images.all-free-download.com/images/graphiclarge/ethereal_image_185195.jpg"
    },
    {
      "link": "https://google.com",
      "name": "name - 2 ",
      "picture": "https://images.all-free-download.com/images/graphiclarge/ethereal_image_185195.jpg"
    }
  ]
}

请注意,即使您在 child_attachments 中添加了链接,您也必须为 post 提供“链接”参数


推荐阅读