public PostToFacebook ( string ImageName, |
||
ImageName | string | |
fbClient | ||
Résultat | void |
// // GET: /Image/ public ActionResult DisplayImage(string filename) { int UserID = WebSecurity.CurrentUserId; if (Request.QueryString["code"] != null) { SocialMediaTools socTools = new SocialMediaTools(); var fb = new FacebookClient(); string accessCode = Request.QueryString["code"].ToString(); dynamic result = fb.Post("oauth/access_token", new { client_id = "333143620161224", //This is my facebook APP ID client_secret = "48a7bbdec0e82f32af25681980b288d0", //The APP's SECRET ID redirect_uri = Request.Url.AbsoluteUri.ToString(), code = accessCode //Code used to swap for Token }); //Check result object for the token var accessToken = result.access_token; //Throw Token into a session, incase we might need later Session["AccessToken"] = accessToken; //Attach Token to Current Clients token paramater fb.AccessToken = accessToken; //Start Upload, passing filename and currently open client socTools.PostToFacebook(filename, fb); //Completed Response.Redirect("./../Home/Album"); return View(); } else { var files = from f in dbContext.Files where f.UserID == UserID && f.Filename == filename select f; ViewBag.Tags = PAWA.Classes.DisplayImage.GetTags(dbContext, files.First().Tags); int value = files.SingleOrDefault().FileID; ViewBag.FolderId = files.SingleOrDefault().FolderID; return View(files.First()); } }