在我的 Facebook 页面上允许我的应用 post

Allow my app post on my facebook page

我在 facebook 中有一个聊天机器人,可以接收用户的图片并进行一些调整。

然后,我希望聊天机器人自动 post Facebook 页面上的图像。有办法实现吗?

是的,总有办法。 下面是我将如何做到这一点。

首先阅读this如何使用图表的页面部分-api。

您需要为您的应用授予这些权限 https://developers.facebook.com/docs/facebook-login/permissions#reference-manage_pagesmanage_pagespublish_pages 允许您的应用在页面上 post。

第 1 步。您的机器人将图像发送到服务器进行处理。

第 2 步。将 graph-api sdk 添加到您的项目中。(您可能已经有了)

第 3 步。获取您要 post 到

的页面的 ID

第 4 步。由于您要上传图片,因此您需要勾选此 posting photos to facebook page via graph-api 到 post 您的图片。 它基本上是向 https://graph.facebook.com/ /v2.8/{page-id}/photos 发送一个 POST 请求,并将图像作为名为 source.

的参数

1: Attach the photo as multipart/form-data. The name of the object doesn't matter, but historically people have used source as the parameter name for the photo. How this works depends on the SDK you happen to be using to do the post.

2: Use a photo that is already on the internet by publishing using the url parameter:

现在,如果一切设置正确,您应该能够post从您的服务器到能够添加字幕等的页面。