skip to Main Content

I am trying to upload a single video on facebook using the latest https://graph-video.facebook.com graph api. Following is my code:

public void ExternalShare()
{
try
{
    var fbp = new FacebookClient("user_access_token");

    dynamic parameters = new ExpandoObject();
    parameters.source = new FacebookMediaObject { ContentType = "multipart/form-data", FileName = "SampleVideo2" }.SetValue(System.IO.File.ReadAllBytes(@"C:VideoSampleVideo2.mp4"));
    parameters.title = "Small New Video";
    parameters.description = "Having Fun";
    string url = "https://graph-video.facebook.com" + "facebook_User_Id" + "/videos";
    dynamic result = fbp.Post(url, parameters); 

}
catch (Exception ex)
{

    throw;
}         

}

After execution. this code giving no exception but every time i execute i am receiving the same id as a response:

enter image description here

Question 2: If there is no exception then this video is not showing on my timeline

2

Answers


  1. According to https://developers.facebook.com/docs/graph-api/reference/video

    When including a source parameter, you should include a filename with
    the correct extension that indicates the type of file container

    Just add .mp4 to the FileName

    FileName = "SampleVideo2.mp4"
    
    Login or Signup to reply.
  2. I know its Old Question but I found the error in it.so Hopefully it Helps Others.

     string url = "https://graph-video.facebook.com" + "facebook_User_Id" + "/videos";
    

    this Line Missing ‘/’ after facebook.com so it should be like this

     string url = "https://graph-video.facebook.com/" + "facebook_User_Id" + "/videos";
    

    and Problem Solved.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search