使用 Graph API 在 Facebook 上将 Base64 图像上传为 post

Upload Base64 image as post on facebook using GraphAPI

我想在 angular 6

中使用 facebook 开发人员图表 API 将 base64 图像(jpg、png)上传到 facebook

'https://graph.facebook.com/me/photos' 这个 api 我正在使用传递表单数据。 我指的是 https://www.devils-heaven.com/facebook-javascript-sdk-photo-upload-from-canvas/

socailpostCall(imageResult) {
  let xhr: XMLHttpRequest = new XMLHttpRequest();
  let formData = new FormData();
  formData.append("access_token",{access_token});
  formData.append("source", imageResult);
  return this._http.post('https://graph.facebook.com/me/photos',formData)
}

我希望图像应该作为 post 上传到 facebook,但实际上它显示

{
   "error": {
      "message": "(#200) This endpoint is deprecated since the required permission publish_actions is deprecated",
      "type": "OAuthException",
      "code": 200,
      "fbtrace_id": "AckVrByZBvyDeuoac00SVXN"
   }
}

错误消息告诉您无法再post 到用户配置文件。您只能将此用于 post 页面 - 使用包含 publish_pages 权限的页面令牌。

更多信息:https://developers.facebook.com/docs/graph-api/reference/page/photos/#Creating

当您参考文档时,您可以看到以下端点已被弃用

Apps that have used these endpoints in the last 90 days (before 30th april) can continue using them with API versions 3.2 and lower until July 30th, 2019.

https://developers.facebook.com/docs/graph-api/changelog/4-30-2019-endpoint-deprecations