Hi
How to post video on Facebook page using c#
Thanks
Hi
How to post video on Facebook page using c#
Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Daniel WrightRank #2,947 · 489 reputationPosted Apr 13, 2025, 5:40 AM EDT
Hello! It seems like you're interested in programmatically posting a video on a Facebook page using C#. To achieve this, you can leverage the Facebook Graph API, which allows you to interact with Facebook's data using HTTP requests.
Here's a high-level overview of the steps involved in posting a video on a Facebook page using C# and the Facebook Graph API:
1. Obtain Access Token: You'll need to generate a Facebook Access Token with the necessary permissions to post on the page. Make sure to use a Page Access Token for posting on behalf of a page.
2. Upload the Video: Use the Facebook Graph API to upload the video file. You can do this by making a `POST` request to `/page-id/videos` endpoint with the video file as multipart data.
3. Retrieve Video ID: Once the video is uploaded, the API response will contain the Video ID. Make sure to save this ID for the next step.
4. Post Video on Page: Now, create a new post on the Facebook page using the Video ID obtained in the previous step. You can make a `POST` request to `/page-id/feed` endpoint with the Video ID and any accompanying message.
Below is a simplified example using the Facebook SDK for .NET in C# to post a video on a Facebook page:
var fbClient = new Facebook.FacebookClient("YOUR_PAGE_ACCESS_TOKEN"); dynamic parameters = new System.Dynamic.ExpandoObject(); parameters.source = new FacebookMediaObject { ContentType = "video/mp4", FileName = "video.mp4" }.SetValue(System.IO.File.ReadAllBytes("path/to/video.mp4")); parameters.description = "Check out this video!"; dynamic result = fbClient.Post("page-id/videos", parameters); // Retrieve Video ID from 'result' and use it to post on the page feedRemember to handle exceptions, validate inputs, and consider error handling in your implementation. Also, ensure you comply with Facebook's policies and guidelines when posting content.
I hope this explanation helps you get started with posting videos on a Facebook page using C#. If you have any more questions or need further clarification, feel free to ask!
Muhammad Imran AnsariRank #326 · 7.6K reputationPosted Apr 13, 2025, 1:21 PM EDT
Hello Ramco,
Posting a video to a Facebook Page using C# involves interacting with the Facebook Graph API. Here's a complete step-by-step guide to help you upload a video to a page programmatically.
Posting a video to a Facebook Page using C# involves interacting with the Facebook Graph API. Here's a complete step-by-step guide to help you upload a video to a page programmatically.
Prerequisites
Facebook Developer Account
A Facebook App created in the Meta Developer Portal
A Page Access Token with
pages_manage_postsandpages_read_engagementpermissionsThe video file you want to upload
Optional: Install a C# HTTP client like
HttpClientto make API requestsStep-by-Step Process
Step 1: Get Page Access Token
To post as a Page, you’ll need to:
Get a User Access Token with
pages_show_listandpages_manage_posts.Use it to retrieve a Page Access Token via:
The response will include the Page's access token.
Step 2: Use Graph API to Upload Video
Use a
POSTrequest to:Step 3: C# Code to Upload Video
using System; using System.IO; using System.Net.Http; using System.Net.Http.Headers; using System.Threading.Tasks; public class FacebookVideoUploader { private static readonly HttpClient _client = new HttpClient(); public static async Task UploadVideoAsync(string pageId, string accessToken, string videoPath, string title, string description) { string uploadUrl = $"https://graph-video.facebook.com/v19.0/{pageId}/videos"; using var content = new MultipartFormDataContent(); content.Add(new StringContent(accessToken), "access_token"); content.Add(new StringContent(title), "title"); content.Add(new StringContent(description), "description"); byte[] videoData = File.ReadAllBytes(videoPath); var videoContent = new ByteArrayContent(videoData); videoContent.Headers.ContentType = MediaTypeHeaderValue.Parse("video/mp4"); // or video/quicktime etc. content.Add(videoContent, "source", Path.GetFileName(videoPath)); var response = await _client.PostAsync(uploadUrl, content); string result = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { Console.WriteLine("Video uploaded successfully!"); Console.WriteLine(result); // Contains video ID } else { Console.WriteLine("Error uploading video:"); Console.WriteLine(result); } } }Step 4: Call the Method
await FacebookVideoUploader.UploadVideoAsync( pageId: "YOUR_PAGE_ID", accessToken: "YOUR_PAGE_ACCESS_TOKEN", videoPath: @"C:\Videos\myvideo.mp4", title: "My Demo Video", description: "This video was uploaded using C# and the Facebook Graph API." );Permissions & Notes
Your access token must have the correct permissions.
Facebook sometimes reviews apps before granting full posting permissions.
Video file size and duration limits apply depending on the account.
Facebook recommends using Graph Video API instead of the normal Graph API for video uploads.
Good Luck!