c# - Post Photos and Videos on Facebook Wall -
i need post photos, videos on facebook walls mvc
app. i'm getting below error (oauthexception - #2500) active access token must used query information current user.
please me. please find below code 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"); media.setvalue(img); postparameters["source"] = media; postparameters["access_token"] = result.access_token; var result1 = client.post(string.format("https://graph.facebook.com/{0}/photos", "<<user id>>"), postparameters);
you need generate access token https://developers.facebook.com/tools/explorer , 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 }.setvalue(imagebytes); client.post(pageid+ "/photos", parameters);
hope help.
Comments
Post a Comment