Post Photos and Videos on Facebook Wall

I need to post Photos, Videos on Facebook walls from my MVC app. I'm getting below error (OAuthException - #2500) An active access token must be used to query information about the current user.

Please help me. Please find below code which I'm using.

  string appID = string.Empty;
  string appSecretCode = string.Empty;
  appID = "<<application Id>>";
  appSecretCode = "<<app secretcode>>";
  var fb = new FacebookClient();
  dynamic result = fb.Get("oauth/access_token", new
      client_id = appID,
      client_secret = appSecretCode,
      grant_type = "client_credentials",
      scope = "publish_stream"
  string accessToken = result.access_token;
  var client = new FacebookClient(accessToken);
  var postparameters = new Dictionary<string, object>();
  var media = new FacebookMediaObject
      FileName = @"Bday.jpg",
      ContentType = "image/jpeg"
  byte[] img = System.IO.File.ReadAllBytes(@"C:\Users\user\Desktop\Bday.jpg");
  postparameters["source"] = media;
  postparameters["access_token"] = result.access_token;
  var result1 = client.Post(String.Format("{0}/photos", "<<User ID>>"), postparameters); 


You need to generate access token from and try:

required AcccountId, pageid

dynamic parameters = new ExpandoObject();
parameters.message =modelList.message;
parameters.subject = modelList.subject;
parameters.account_id = modelList.AcccountId;

imageBytes =  byte[] of image

parameters.source = new FacebookMediaObject{
    ContentType = imageType,
    FileName = Url

client.Post(pageid+ "/photos", parameters);

Hope it will help.

Need Your Help

Is there any way to show output during update-database?

c# entity-framework

I'm running a fairly large seed as a stress test, and I'm wondering if it's possible to show output to a console.

Unable to add SSL support for database

spring hibernate postgresql ssl

I am using Spring3, Hibernate4 and postgres9.2.