如何通过Instagram Graph API发布Reels?发布失败求助
求助:使用Instagram Graph API发布Reels失败问题排查
概述
一直尝试使用Instagram API发布Reels,但所有尝试均未成功。
我的配置
- 使用developers.facebook.com上的未审核应用
- 目标是在自己拥有的Instagram企业账户上发布内容
- 该账户已作为Instagram测试账户添加到应用中
参考文档
遵循developers.facebook.com上的内容发布相关文档
操作流程
步骤1:OAuth授权
在开发者控制台完成授权,获取的令牌拥有以下权限:
- business_basic
- business_manage_messages
- business_content_publish
- business_manage_comments
步骤2:创建媒体容器
完全按照文档编写代码,此步骤能成功获取容器ID:
def create_instagram_media_container(ig_id: str, video_url: str, access_token: str): url = f"https://graph.instagram.com/v20.0/{ig_id}/media" headers = { "Content-Type": "application/json", } data = { "media_type": "REELS", "video_url": video_url } response = requests.post(url, headers=headers, json=data) if response.status_code == 200: return response.json() else: response.raise_for_status()
注:尝试过在请求头中添加"Authorization": f"OAuth {access_token}",以及在请求数据中添加"upload_type": "resumable",均未解决后续问题。
步骤3:发布容器
按文档编写代码,但此步骤出现错误:
def upload_instagram_video(ig_id: str, ig_container_id: str, access_token: str): url = f"https://graph.instagram.com/v20.0/{ig_id}/media_publish" headers = { "Content-Type": "application/json" } data = { "creation_id": ig_container_id, } response = requests.post(url, headers=headers, json=data) if response.status_code == 200: return response.json() else: response.raise_for_status()
最初的错误信息:
b'{"error":{"message":"Unsupported post request. Object with ID \'[...]\\' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api","type":"GraphMethodException","code":100,"error_subcode":33,"fbtrace_id":"AKe1_Gl1c5kNSTrKHPYuyHG"}}'
现在仅收到400错误,提示"Sorry, this content isn't available right now"。
注:尝试在请求头中添加"Authorization": f"OAuth {access_token}",问题仍未解决。
我的疑问
对问题根源有以下猜测,但找不到解决方向:
- 端点:使用的是
graph.instagram.com端点,也尝试过graph.facebook.com端点但未成功。选择前者是因为文档说明该API无需关联Facebook页面,操作更简单,但后者支持caption等额外字段。 - 令牌:查阅资料时看到有人提到page token和user token的区别,但自己的令牌是从开发者网站的"Instagram"标签直接生成的,没有这种区分。根据迁移指南,自己使用的是带Instagram登录的Instagram API,不确定是否需要区分令牌类型。
内容的提问来源于stack exchange,提问作者Victor
相关产品推荐
相关产品推荐

