Why published reel is private after using Facebook with graph API and Python?
New reel does appear in fan page's Reels feed but it's invisible to users (i used another account to display the same feed and new reel is not there).
My "Page" perms:
publish_video pages_show_list pages_read_engagement pages_manage_posts
Using this Python code to publish Facebook reel:
import os import requests from os.path import isfile page_id= 'your business page id' api_version= 'v20.0' page_access_token= 'your_page_token' def initialize_upload(): url = f"https://graph.facebook.com/{api_version}/{page_id}/video_reels" payload = { 'upload_phase': 'start', 'access_token': page_access_token } r = requests.post(url, data=payload) json = r.json() if r.status_code == 200: video_id = r.json()['video_id'] else: raise Exception(json) return video_id def process_upload(video_id, file_size, file_data): url = f'https://rupload.facebook.com/video-upload/{api_version}/{video_id}' payload = { 'Authorization': 'OAuth ' + page_access_token, 'offset': '0', 'file_size': str(file_size), 'Content-Type': 'application/octet-stream' } r = requests.post(url, data=file_data, headers=payload) json = r.json() if r.status_code != 200: raise Exception(json) def publish(video_id, description, publish_time=None): url = f"https://graph.facebook.com/{api_version}/{page_id}/video_reels" payload = { 'access_token': page_access_token, 'video_id': video_id, 'upload_phase': 'finish', 'description': description, } if publish_time: payload['video_state'] = 'SCHEDULED' payload['scheduled_publish_time'] = publish_time else: payload['video_state'] = 'PUBLISHED' r = requests.post(url, data=payload) json = r.json() if r.status_code != 200: raise Exception(json) if __name__ == '__main__': video_id = initialize_upload() print(video_id) mp4_path= r"C:\test\Facebook.mp4" if isfile(mp4_path): file_size = os.path.getsize(mp4_path) file_data= open(mp4_path, 'rb') process_upload(video_id, file_size, file_data) publish(video_id, '#description') else: print('File not found')
Metadata (those views are mine):
{'comments': {'data': [], 'summary': {'can_comment': True, 'order': 'chronological', 'total_count': 0}}, 'created_time': '2024-08-13T16:22:02+0000', 'description': '#test', 'from': {'id': '***', 'name': 'Test'}, 'id': '***', 'is_crossposting_eligible': True, 'likes': {'data': [], 'summary': {'can_like': True, 'has_liked': False, 'total_count': 0}}, 'permalink_url': '/reel/***/', 'privacy': {'allow': '', 'deny': '', 'description': 'Public', 'friends': '', 'networks': '', 'value': 'EVERYONE'}, 'status': {'copyright_check_status': {'matches_found': False, 'status': 'complete'}, 'processing_phase': {'status': 'complete'}, 'publishing_phase': {'publish_status': 'published', 'publish_time': '2024-08-13T17:33:12+0000', 'status': 'complete'}, 'uploading_phase': {'bytes_transferred': 13671054, 'status': 'complete'}, 'video_status': 'ready'}, 'views': 45}
Any idea why is it private?
The problem was missing permission.
Here are Page perms you need to create public reel:
publish_video pages_show_list pages_read_engagement pages_manage_posts public_profile