Daniel Cambría
Daniel Cambría

Reputation: 247

how to "Create post with video" using Facebook API?

I'm trying to create a new post in my fanpage with an already uploaded and posted video. Into the page menu -> "Publishing Tools" -> "Video Library" it is possible to click on published video and make a new post, but I don't get how to create this new post+video with Facebooks API.

Upvotes: 1

Views: 2246

Answers (1)

Daniel Cambría
Daniel Cambría

Reputation: 247

Solved!

url = "https://graph.facebook.com/v2.9/me/videos"
title = "some title"               #post title
description = "some description"   #post description
crossposted_video_id = "12344444"  #get the video ID and grab it here!
content_category = "LIFESTYLE"     #there are some more categories to use in fb
scheduled_publish_time = ""        #in unix format
published = "false"                #if you want to schedule, set "false"
token = "page access token"        #you can get one in Graph API Explorer

param = {
    "crossposted_video_id": crossposted_video_id,
    "title": title,
    "description": description,
    "content_category": content_category,
    "scheduled_publish_time": scheduled_publish_time,
    "published": published,
    "access_token": token 
}
r = requests.post(url, json=param)

Upvotes: 1

Related Questions