public ActionResult Index() { var client = new FacebookWebClient(); dynamic me = client.Get("me"); ViewBag.Name = me.name; ViewBag.Id = me.id.ToString(); JokesFeedViewModel model = new JokesFeedViewModel(); model.UserName = me.name; model.UserId = me.id; IJokesRepository jokeRep = new JokesRepository(); IVotesRepository votesRep = new VotesRepository(); List <Jokes> allJokes = jokeRep.GetAllJokesByDate().ToList <Jokes>(); if (allJokes != null) { foreach (Jokes joke in allJokes) { joke.UserVoteType = votesRep.GetCurrentUserVote(joke.JokeId, joke.UserId); joke.UpVotesCount = votesRep.GetJokesVotesCount(joke.JokeId, true); joke.DownVotesCount = votesRep.GetJokesVotesCount(joke.JokeId, false); dynamic jUser = client.Get(joke.UserId.ToString()); joke.UserName = jUser.name; } model.Jokes = allJokes; } return(View(model)); }
private void FacebookSignInMethod() { var client = new FacebookWebClient(); dynamic me = client.Get("me"); Session["CameFromSocialNetwork"] = true; if (Membership.GetUser(me.email) == null) { Session["FacebookUserName"] = me.email; Session["FacebookName"] = me.name; string urlRegister = ConvertRelativeUrlToAbsoluteUrl(HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Register/Register.aspx")); Response.Redirect(urlRegister); } else { //PortalSecurity.SignOn(me.email, GeneratePasswordHash(me.email as String)); Session["UserName"] = me.email; } Response.Redirect(HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/SignIn/LoginIn.aspx")); if (this.Settings["SIGNIN_AUTOMATICALLYHIDE"] != null) { bool hide = bool.Parse(this.Settings["SIGNIN_AUTOMATICALLYHIDE"].ToString()); this.Visible = false; } }
private void LogInUser() { if (!User.Identity.IsAuthenticated) { FacebookWebClient fb = new FacebookWebClient(); dynamic result = fb.Get("me"); long fbId = long.Parse(result.id); AppUser appUser = Ctx.AppUsers.FirstOrDefault(u => u.FacebookId == fbId); if (appUser == null) { appUser = AppUser.CreateAppUser(fbId); Ctx.AppUsers.AddObject(appUser); } else { if (appUser.LastVisited != DateTime.Today) { appUser.LastVisited = DateTime.Today; appUser.InvitationSentToday = 0; } } Ctx.SaveChanges(); FormsService.SignIn(appUser.Id.ToString(), false); } }
public ActionResult LogIn(string returnUrl) { //On the refresh check if the user is logged in with facebook if (FacebookWebContext.Current.IsAuthenticated()) { try { var client = new FacebookWebClient(); dynamic user = client.Get("me"); var userData = this.MembershipService.GetUser(user.email); if (userData == null) { ModelState.AddModelError("", "the facebook user name is not registered."); } else { this.MembershipService.UpdateLastLogin(userData.Email); this.FormsService.SignIn(userData.Email, false, userData.ToString()); if (Url.IsLocalUrl(returnUrl)) { return(Redirect(returnUrl)); } else { return(RedirectToAction("Index", "Home")); } } } catch { } } return(View()); }
protected void Page_Load(object sender, EventArgs e) { var extendedPermissions = ConfigurationManager.AppSettings["extendedPermissions"].Split(','); if (!FacebookWebContext.Current.IsAuthorized(extendedPermissions)) { // this sample actually does not make use of FormsAuthentication, // besides redirecting to the proper login url defined in web.config // this will also automatically add ReturnUrl. FormsAuthentication.RedirectToLoginPage(); } else { // checking IsPostBack may reduce the number of requests to Facebook server. if (!IsPostBack) { var fb = new FacebookWebClient(); dynamic me = fb.Get("me"); imgProfilePic.ImageUrl = string.Format("https://graph.facebook.com/{0}/picture", me.id); lblName.Text = me.name; lblFirstName.Text = me.first_name; lblLastName.Text = me.last_name; } } }
private Core.Entities.User AcceptFacebookOAuthToken(FacebookOAuthResult facebookOAuthResult) { Condition.Requires(facebookOAuthResult).IsNotNull(); // Grab the code. string code = facebookOAuthResult.Code; // Grab the access token. FacebookOAuthClient facebookOAuthClient = FacebookOAuthClient; dynamic result = facebookOAuthClient.ExchangeCodeForAccessToken(code); var oauthData = new OAuthData { OAuthProvider = OAuthProvider.Facebook, AccessToken = result.access_token, ExpiresOn = DateTime.UtcNow.AddSeconds(result.expires) }; // Now grab their info. var facebookWebClient = new FacebookWebClient(oauthData.AccessToken); dynamic facebookUser = facebookWebClient.Get("me"); oauthData.Id = facebookUser.id; // Not sure how to Inject an IUserService because it requires a Session .. which I don't have. var userService = new UserService(DocumentSession); // Now associate this facebook user to an existing user OR create a new one. return(userService.CreateOrUpdate(oauthData, facebookUser.username, facebookUser.name, facebookUser.email)); }
/// <summary> /// Get FB info of the user, save the recommendation into our SimpleDB and then redirect to a web page that posts to the uers's wall. /// </summary> private void ShowFacebookContent() { var fb = new FacebookWebClient(); dynamic myInfo = fb.Get("me"); string myFBId = myInfo["id"];; if (SaveRecoToSimpleDB(myFBId)) { Response.Redirect("posttowall.htm?rn=" + RecoName.Text + "&rc=" + RecoCity.Text + "&rs=" + RecoService.SelectedValue); } }
public ActionResult Profile() { var client = new FacebookWebClient(); dynamic me = client.Get("me"); ViewBag.Name = me.name; ViewBag.Id = me.id; return(View()); }
private void ShowFacebookContent() { var fb = new FacebookWebClient(); dynamic myInfo = fb.Get("me"); lblName.Text = myInfo.name; pnlHello.Visible = true; dynamic myFriendsInfo = fb.Get("me/friends"); foreach (var friend in myFriendsInfo.data) { FriendsList.Items.Add(friend.name); } /* OR */ //var fbApp = new FacebookApp(); //dynamic info = fbApp.Get("me"); //lblName.Text = info.name; //pnlHello.Visible = true; }
protected void Page_Load(object sender, EventArgs e) { if (CanvasAuthorizer.Authorize()) { var fb = new FacebookWebClient(); dynamic me = fb.Get("me"); imgProfilePic.ImageUrl = string.Format("https://graph.facebook.com/{0}/picture", me.id); lblName.Text = me.name; lblFirstName.Text = me.first_name; lblLastName.Text = me.last_name; } }
public ActionResult Index() { var fb = new FacebookWebClient(); dynamic me = fb.Get("me"); ViewBag.ProfilePictureUrl = string.Format("http://graph.facebok.com/{0}/picture", me.id); ViewBag.Name = me.name; ViewBag.FirstName = me.first_name; ViewBag.LastName = me.last_name; ViewBag.MessagePostSuccess = Request.QueryString.AllKeys.Contains("success") && Request.QueryString["success"] == "True"; return(View()); }
public ActionResult Listas() { var client = new FacebookWebClient(); dynamic me = client.Get("me"); tcc_imoveisEntities tcc = new tcc_imoveisEntities(); IEnumerable <Pesquisa_Result> pesquisa_result = tcc.ListaPesquisaUsuario(long.Parse(me.id)); ViewBag.pesquisas = pesquisa_result.ToList(); return(View()); }
private void UpdateProfile() { var client = new FacebookWebClient(); dynamic me = client.Get("me"); ProfileManager.Provider.ApplicationName = PortalSettings.PortalAlias; ProfileBase profile = ProfileBase.Create(me.email); profile.SetPropertyValue("Email", me.email); profile.SetPropertyValue("Name", me.name); try { profile.Save(); } catch (Exception exc) { ErrorHandler.Publish(LogLevel.Error, "Error al salvar un perfil", exc); } }
public JsonResult SavePesquisa(string nomePesquisa) { if (FacebookWebContext.Current.IsAuthenticated()) { int idPesquisa = Convert.ToInt32(System.Web.HttpContext.Current.Session["pesquisa_id"]); var client = new FacebookWebClient(); dynamic me = client.Get("me"); using (tcc_imoveisEntities tcc = new tcc_imoveisEntities()) { tcc.SalvaPesquisa(idPesquisa, me.id, nomePesquisa); } return(Json(true)); } return(Json(false)); }