public void FacebookLogin() { fbWebContext = FacebookWebContext.Current; //get facebook session if (FacebookWebContext.Current.Session != null) { var app = new FacebookWebClient(); var me = (IDictionary<string, object>)app.Get("me"); // get own information _FacebookUid = fbWebContext.UserId ; // get own user id try { string fbName = (string)me["first_name"] + " " + (string)me["last_name"]; // get first name and last name if (OnFacebookLogin(fbName)) { SaveSessionInDB(); return; } else { string notice = string.Format("<h2>Welcome, {0}.</h2>" + "<h3>Login here to connect your Facebook login to your account<br/>" + "Or sign-up to create full account, connected with your Facebook credentials</h3>", fbName); } } catch (Exception ex) { } } }
// // GET: /User/ public ActionResult Index(string id) { 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; dynamic jUser = client.Get(id.ToString()); string userName= jUser.name; IJokesRepository jokeRep = new JokesRepository(); IVotesRepository votesRep = new VotesRepository(); List<Jokes> allJokes = jokeRep.GetJokesByUserId(int.Parse(id)).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); joke.UserName=userName; } model.Jokes = allJokes; } ViewBag.Name = userName +"'s Page"; return View("PostsMain", model); }
public ActionResult About() { var app = new FacebookWebClient(); dynamic me = app.Get("me"); dynamic friends = app.Get("/me/friends"); dynamic model = new ExpandoObject(); model.Name = me.name; model.FriendCount = friends.data.Count; return View(model); }
public ActionResult RegisterLogOn(RegisterLogOnViewModel viewModel, string returnUrl) { if (FacebookWebContext.Current.IsAuthenticated()) { var client = new FacebookWebClient(); dynamic me = client.Get("me"); if (!_userRepository.UserExist(me.username)) { var user = new User(AuthenticationType.Facebook) { Username = me.username }; _userRepository.Add(user); _unitOfWork.Commit(); } FormsAuthentication.SetAuthCookie((string)me.username, false); if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) return Redirect(returnUrl); return RedirectToAction("Index", "Home"); } return View("RegisterLogOn", viewModel); }
public void BindData() { AppUser usr = ContextHelper.DataContext.User.First(o => o.UserId == SessionHelper.UserId); FacebookWebContext wc = new FacebookWebContext(GlobalObjects.FBApp); FacebookWebClient fb = new FacebookWebClient(wc); fb.AccessToken = usr.AccessToken; dynamic friends = fb.Get("/me/friends"); List<string> userIds = new List<string>(); foreach (dynamic friend in friends.data) userIds.Add(friend.id); if (userIds.Count() > 0) { DataTable dt = AppUserDao.GetUsersInfo(userIds); if (dt.Rows.Count > 0) { dlFriends.DataSource = dt; dlFriends.DataBind(); } else { CommonFunctions.ShowInfo(lblStatus, "No friends found at timeflies"); } } else { CommonFunctions.ShowInfo(lblStatus, "No friends found at timeflies"); } }
public ActionResult About() { var fb = new FacebookWebClient(); dynamic result = fb.Get("me"); ViewData["Firstname"] = (string)result.first_name; ViewData["Lastname"] = (string)result.last_name; 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) { CanvasUrlBuilder = new CanvasUrlBuilder(FacebookApplication.Current, new HttpRequestWrapper(Request)); var client = new FacebookWebClient(); PicUrlWebClient = ((dynamic)client.Get("/4", new Dictionary<string, object> { { "fields", "picture" } })).picture; var app = new FacebookApp(); PicUrlApp = ((dynamic)app.Get("/4", new Dictionary<string, object> { { "fields", "picture" } })).picture; }
public ActionResult Profile() { var client = new FacebookWebClient(); dynamic me = client.Get("me"); ViewBag.Name = me.name; ViewBag.Id = me.id; return View(); }
/// <summary> /// Check if the Facebook App has permissions from the specified user. /// </summary> /// <param name="context"> /// The Facebook web context. /// </param> /// <param name="accessToken"> /// The access token. /// </param> /// <param name="appId"> /// The app id. /// </param> /// <param name="userId"> /// The user id. /// </param> /// <param name="permissions"> /// The list of permissions. /// </param> /// <returns> /// The list of permissions that are allowed from the specified permissions. /// </returns> internal static string[] HasPermissions(FacebookWebContext context, string accessToken, string appId, long userId, string[] permissions) { if (context == null) { throw new ArgumentNullException("context"); } if (string.IsNullOrEmpty(appId)) { throw new ArgumentNullException("appId"); } if (userId < 0) { throw new ArgumentOutOfRangeException("userId", "userId must be equal or greater than 0"); } if (userId != 0 && !string.IsNullOrEmpty(accessToken)) { try { var fb = new FacebookWebClient(context) { AccessToken = accessToken }; var remoteResult = ((IDictionary <string, object>)fb.Get("me/permissions")); if (remoteResult != null && remoteResult.ContainsKey("data")) { var data = remoteResult["data"] as IList <object>; if (data != null && data.Count > 0) { var permData = data[0] as IDictionary <string, object>; if (permData == null) { return(new string[0]); } else { return((from perm in permData where perm.Value.ToString() == "1" select perm.Key).ToArray()); } } } } catch (FacebookOAuthException) { return(null); } } return(null); }
// // GET: /FacebookLogin/ public ActionResult Index() { if (FacebookWebContext.Current.IsAuthenticated()) { var client = new FacebookWebClient(); dynamic me = client.Get("me"); ViewBag.Name = me.name; ViewBag.Id = me.id; ViewBag.Email = me.email; } return View(); }
protected void Page_Load(object sender, EventArgs e) { CheckIfFacebookAppIsSetupCorrectly(); var fbWebContext = FacebookWebContext.Current; if (fbWebContext.IsAuthorized()) { var fb = new FacebookWebClient(fbWebContext); dynamic result = fb.Get("/me"); lblMessage.Text = "Hi " + result.name; } }
private void ShowFacebookContent() { var fb = new FacebookWebClient(); dynamic myInfo = fb.Get("me"); lblName.Text = myInfo.name; pnlHello.Visible = true; /* OR */ //var fbApp = new FacebookApp(); //dynamic info = fbApp.Get("me"); //lblName.Text = info.name; //pnlHello.Visible = true; }
/// <summary> /// Get friend infos /// </summary> /// <param name="fid">Facebook Id of the requested user</param> /// <returns>A Json Array</returns> public static JsonObject GetFriendInfo(long fid) { try { var fb = new FacebookWebClient(); return (JsonObject)fb.Get("/" + fid); } catch (Exception ex) { _logger.Error("Cannot get friendsInfo", ex); Debug.WriteLine(ex); return null; } }
/// <summary> /// Get friend's name from its fid /// </summary> /// <param name="fid">Friend's fid</param> public static string GetFriendName(long fid) { try { var fb = new FacebookWebClient(); dynamic result = fb.Get("/" + fid); return (result.last_name + " " + result.first_name); } catch (Exception ex) { _logger.Error("Cannot get friendsName", ex); Debug.WriteLine(ex); return null; } }
/// <summary> /// Get friend infos /// </summary> /// <param name="fid">Facebook Id of the requested user</param> /// <returns>A Json Array</returns> public static dynamic GetFriendInfo(long fid) { try { var fb = new FacebookWebClient(); dynamic result = fb.Get("/" + fid); return result; } catch (Exception ex) { _logger.Error("Cannot get friendsInfo", ex); Debug.WriteLine(ex); return null; } }
public bool IsFbFriend(string videoUserId, string friendUserId) { AppUser usr = ContextHelper.DataContext.User.First(o => o.UserId == videoUserId); FacebookWebContext wc = new FacebookWebContext(GlobalObjects.FBApp); FacebookWebClient fb = new FacebookWebClient(wc); fb.AccessToken = usr.AccessToken; dynamic friends = fb.Get("/me/friends"); List<string> userIds = new List<string>(); foreach (dynamic friend in friends.data) userIds.Add(friend.id); return userIds.Contains(friendUserId); }
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(); }
/// <summary> /// Get friend's name from its fid /// </summary> /// <param name="fid">Friend's fid</param> public static string GetFriendName(long fid) { try { var fb = new FacebookWebClient(); var result = (JsonObject)fb.Get("/" + fid); return (result["last_name"] + " " + result["first_name"]); } catch (Exception ex) { _logger.Error("Cannot get friendsName", ex); Debug.WriteLine(ex); return null; } }
public ActionResult Profile() { if (FacebookWebContext.Current.IsAuthenticated()) { var client = new FacebookWebClient(); dynamic me = client.Get("me"); ViewBag.Friends = me; ViewBag.ShouldConnect = false; } else { ViewBag.ShouldConnect = true; } return View(); }
private static List<Images> GetFriendImages(string userToken, TimeFliesByEntities dc) { FacebookWebContext wc = new FacebookWebContext(GlobalObjects.FBApp); FacebookWebClient fb = new FacebookWebClient(wc); fb.AccessToken = userToken; dynamic friends = fb.Get("/me/friends"); List<Images> images = new List<Images>(); foreach (dynamic friend in friends.data) { string friendId = friend.id; Images image = dc.Images.Where(o => o.UserId == friendId).OrderByDescending(o => o.ImageId).FirstOrDefault(); if (image != null) images.Add(image); } return images.OrderByDescending(o => o.DateAdded).Take(5).ToList(); }
/// <summary> /// Check if the Facebook App has permissions from the specified user. /// </summary> /// <param name="appId"> /// The app id. /// </param> /// <param name="appSecret"> /// The app secret. /// </param> /// <param name="userId"> /// The user id. /// </param> /// <param name="permissions"> /// The list of permissions. /// </param> /// <returns> /// The list of permissions that are allowed from the specified permissions. /// </returns> internal static string[] HasPermissions(string appId, string appSecret, long userId, string[] permissions) { Contract.Requires(!string.IsNullOrEmpty(appId)); Contract.Requires(!string.IsNullOrEmpty(appSecret)); Contract.Requires(permissions != null); Contract.Requires(userId >= 0); Contract.Ensures(Contract.Result <string[]>() != null); var result = new string[0]; if (userId != 0) { var perms = new StringBuilder(); for (int i = 0; i < permissions.Length; i++) { perms.Append(permissions[i]); if (i < permissions.Length - 1) { perms.Append(","); } } var query = string.Format(CultureInfo.InvariantCulture, "SELECT {0} FROM permissions WHERE uid == {1}", perms, userId); var parameters = new Dictionary <string, object>(); parameters["query"] = query; parameters["method"] = "fql.query"; var fb = new FacebookWebClient(appId, appSecret); var data = fb.Get(parameters) as IList <object>; if (data != null && data.Count > 0) { var permData = data[0] as IDictionary <string, object>; if (permData != null) { result = (from perm in permData where perm.Value.ToString() == "1" select perm.Key).ToArray(); } } } return(result); }
public string AuthenticateUser(string userId, string token) { try { using (TimeFliesByEntities dc = new TimeFliesByEntities(Settings.EFConnectionString)) { string videoId = "id_"; if (dc.User.Count(o => o.UserId == userId) > 0) { videoId += dc.Videos.First(o => o.UserId == userId).VideoId; } else // Add New User { FacebookWebContext wc = new FacebookWebContext(GlobalObjects.FBApp); FacebookWebClient fb = new FacebookWebClient(wc); fb.AccessToken = token; dynamic result = fb.Get("/me"); string fbEmail = result.email ?? String.Empty; userId = result.id; videoId += RegisterUser(result.id, result.email, result.first_name + " " + result.last_name, token); /* const string username = "******"; Person userData = FacebookSvc.GetUserData(token, username); string FQLquery = "https://api.facebook.com/method/fql.query?query=select%20email%20from%20user%20where%20uid%3D" + userData.id + "&access_token=" + token + ""; string resp = new oAuthFacebook().WebRequest(oAuthFacebook.Method.GET, FQLquery, string.Empty); DataSet ds = new DataSet(); StringReader xmlReader = new StringReader(resp); ds.ReadXml(xmlReader); string email = ds.Tables[1].Rows[0][0].ToString(); videoId += RegisterUser(userData.id, email, userData.first_name + " " + userData.last_name, token); */ } return videoId; } } catch (Exception ex) { EmailService.ErrorEmail(ex); return ex.Message; } }
public ActionResult Index() { var fb = new FacebookWebClient(); dynamic me = fb.Get("me"); ViewBag.id = me.id; ViewBag.name = me.name; ViewBag.firstname = me.first_name; FriendLikesService service = new FriendLikesService(me.id, fb.AccessToken); ViewBag.webUrl = RoleEnvironment.GetConfigurationSettingValue("WebURL"); ViewBag.blobUrl = RoleEnvironment.GetConfigurationSettingValue("BlobURL"); if (service.isCached()) { //// The data is cached, we can retrieve it and use it server-side... //// The ViewBag is used by the default Index view //service.GetFriendsLikes(); //ViewBag.friendLikes = service.GetOrderedFriendLikes(); //var cats = service.GetCategories().OrderByDescending(k => k.Value).ToList(); //var max = cats.Max(k => k.Value); //var min = cats.Min(k => k.Value); //ViewBag.categories = cats; //ViewBag.max = max; //ViewBag.min = min; // Return the IndexJS view to use the cached data on the client return View("IndexJS"); } else { // Need to send this to the Worker Role service.QueueLike(); return View("PleaseWait"); } return View(); }
public ActionResult Index() { ViewBag.Message = "Welcome to ASP.NET MVC!"; ViewBag.fb_loggedIn = false; if (FacebookWebContext.Current != null) { if (FacebookWebContext.Current.IsAuthenticated()) { var client = new FacebookWebClient(); dynamic me = client.Get("me"); ViewBag.fb_loggedIn = true; ViewBag.FirstName = me.first_name; ViewBag.LastName = me.last_name; ViewBag.Id = me.id; ViewBag.Picture = me.picture; ViewBag.Email = me.email; } } return View(); }
public void FacebookLogin() { fbwebContext = FacebookWebContext.Current; if (FacebookWebContext.Current.Session != null) { _FacebookUid = fbwebContext.UserId; try { var fbwc = new FacebookWebClient(FacebookWebContext.Current.AccessToken); var me = (IDictionary<string, object>)fbwc.Get("me"); string fbName = (string)me["first_name"] + " " + (string)me["last_name"]; // get first name and last name if (OnFacebookLogin(fbName)) { SaveSessionInDB(); return; } else { string notice = string.Format("<h2>Welcome, {0}.</h2>" + "<h3>Login here to connect your Facebook login to your account<br/>" + "Or sign-up to create full account, connected with your Facebook credentials</h3>", fbName); if (Request.QueryString["ytfblink"] != null) { } else { } } } catch (FacebookOAuthException ex) { } } }
private void SetPanelsVisibility(bool val) { if (ConfigurationManager.AppSettings["ApplicationType"].ToLower() == "yourtribute") { PanelUserName.Visible = val; UpdatePanel1.Visible = val; CityPanel.Visible = val; if (val == false) { PanelPassword.Attributes.Remove("class"); PanelPassword.CssClass = "yt-signup-Password"; PanelConfirmPassword.CssClass = "yt-signup-ConfirmPassword"; SignupNewsLetter.InnerHtml = "I would like to receive periodic newsletters from Your Tribute, including company news and special offers."; } else { PanelPassword.CssClass = "signup-Password"; PanelConfirmPassword.CssClass = "signup-Password"; SignupNewsLetter.InnerHtml = "I would like to receive periodic newsletters, including tips and tricks when creating tributes,from Your Tribute."; } } else { SignupNewsLetter.InnerHtml = "I would like to receive periodic newsletters, including tips and tricks when creating websites,from Your Moments."; } txtEmail.Focus(); lblBusinessAcctDesc.Visible = val; BusinessTypePanel.Visible = val; WebsitePanel.Visible = val; StreetAddressPanel.Visible = val; CompanyNamePanel.Visible = val; ZipCodePanel.Visible = val; PanelPhone.Visible = val; FirstNamePanel.Visible = !val; LastNamePanel.Visible = !val; lblPersonalAcctDesc.Visible = !val; txtWebsiteAddress.Text = ""; txtEmail.Text = ""; // Added For Event Handling - Parul if (Request.QueryString["EventID"] != null) { string email = Request.QueryString["Email"]; txtEmail.Text = email; } else if (Request.QueryString["TributeID"] != null) { if (Request.QueryString["Email"] != null) txtEmail.Text = Request.QueryString["Email"]; } txtUsername.Text = ""; txtPassword.Text = ""; txtConfirmPassword.Text = ""; txtBusinessName.Text = ""; txtFirstName.Text = ""; txtLastName.Text = ""; txtStreetAddress.Text = ""; txtCity.Text = ""; txtPhoneNumber1.Text = ""; txtPhoneNumber2.Text = ""; txtPhoneNumber3.Text = ""; txtZipCode.Text = ""; rfvtxtCity.Visible = val; ddlBusinessType.SelectedIndex = 0; ddlCountry.SelectedIndex = 0; this._presenter.OnStateLoad(Locationid(ddlCountry.SelectedValue)); chkAgreeTermsUse.Checked = false; if (FacebookWebContext.Current.Session != null) { //Display user data captured from the Facebook API. try { var fbwc = new FacebookWebClient(FacebookWebContext.Current.AccessToken); var me = (IDictionary<string, object>)fbwc.Get("me"); string fql = "Select current_location, email from user where uid = " + (string)me["id"]; JsonArray me2 = (JsonArray)fbwc.Query(fql); var mm = (IDictionary<string, object>)me2[0]; txtFirstName.Text = (string)me["first_name"]; txtLastName.Text = (string)me["last_name"]; JsonObject hl = (JsonObject)mm["current_location"]; if ((string)hl[0] != null) { txtCity.Text = (string)hl[0]; setLocationFromFacebookLocation(ddlCountry, (string)hl[2]); this._presenter.OnStateLoad(Locationid(ddlCountry.SelectedValue)); setLocationFromFacebookLocation(ddlStateProvince, (string)hl[1]); } string email_ = string.Empty; // user.proxied_email; string result = (string)mm["email"]; if (!string.IsNullOrEmpty(result)) { email_ = result; } txtEmail.Text = email_; } catch (Exception ex) { if (!PortalValidationSummary.Visible) { string msg = "Problems with Facebook session. Please <a href=\"#\" onclick=\"fb_logout(); return false;\">" + " <img id=\"fb_logout_image\" src=\"http://static.ak.fbcdn.net/images/fbconnect/logout-buttons/logout_small.gif\" alt=\"Connect\"/>" + "</a> and try again." + ex; lblErrMsg.InnerHtml = ShowMessage(headertext, msg, 0); lblErrMsg.Visible = true; } } } }
/// <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); } }
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); }
protected void doFacebookSignup() { var fbwc = new FacebookWebClient(FacebookWebContext.Current.AccessToken); var me = (IDictionary<string, object>)fbwc.Get("me"); string fbName = (string)me["first_name"] + " " + (string)me["last_name"]; string UserName = fbName.ToLower().Replace(" ", "_").Replace("'", "");/*+ "_"+_FacebookUid.ToString()*/ string fql = "Select current_location,pic_square,email from user where uid = " + (string)me["id"]; JsonArray me2 = (JsonArray)fbwc.Query(fql); var mm = (IDictionary<string, object>)me2[0]; Nullable<int> state = null; Nullable<int> country = null; string _UserImage = "images/bg_ProfilePhoto.gif"; if (!string.IsNullOrEmpty((string)mm["pic_square"])) { _UserImage = (string)mm["pic_square"]; // get user image } string city = ""; JsonObject hl = (JsonObject)mm["current_location"]; if ((string)hl[0] != null) { city = (string)hl[0]; UserManager usrmngr = new UserManager(); object[] param = { (string)hl[2],(string)hl[1] }; if (usrmngr.GetstateIdByName(param) > 0) { state = usrmngr.GetstateIdByName(param); } if (usrmngr.GetCountryIdByName((string)hl[2]) > 0) { country = usrmngr.GetCountryIdByName((string)hl[2]); } } string password_ = string.Empty; string email_ = string.Empty; //user.proxied_email; string result = (string)mm["email"]; if (!string.IsNullOrEmpty(result)) { email_ = result; password_ = RandomPassword.Generate(8, 10); password_ = TributePortalSecurity.Security.EncryptSymmetric(password_); } UserRegistration objUserReg = new UserRegistration(); TributesPortal.BusinessEntities.Users objUsers = new TributesPortal.BusinessEntities.Users( UserName, password_, (string)me["first_name"], (string)me["last_name"], email_, "", false, city, state, country, 1, _FacebookUid); objUsers.UserImage = _UserImage; objUserReg.Users = objUsers; /*System.Decimal identity = (System.Decimal)*/ UserInfoManager umgr = new UserInfoManager(); umgr.SavePersonalAccount(objUserReg); if (objUserReg.CustomError != null) { messageText.Text=string.Format("<h2>Sorry, {0}.</h2>" + "<h3>Those Facebook credentials are already used in some other Your Tribute Account</h3>", fbName); } else { SessionValue _objSessionValue = new SessionValue(objUserReg.Users.UserId, objUserReg.Users.UserName, objUserReg.Users.FirstName, objUserReg.Users.LastName, objUserReg.Users.Email, objUserReg.UserBusiness == null ? 1 : 2, "Basic", objUserReg.Users.IsUsernameVisiable); TributesPortal.Utilities.StateManager stateManager = TributesPortal.Utilities.StateManager.Instance; stateManager.Add("objSessionvalue", _objSessionValue, TributesPortal.Utilities.StateManager.State.Session); SaveSessionInDB(); Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", Session.SessionID)); Response.Cookies["ASP.NET_SessionId"].Domain = "." + WebConfig.TopLevelDomain; showDialog.Text = "false"; refreshPage.Text = "true"; } }
private void doFacebookLogin() { var fbwc = new FacebookWebClient(FacebookWebContext.Current.AccessToken); var me = (IDictionary<string, object>)fbwc.Get("me"); string fbName = (string)me["first_name"] + " " + (string)me["last_name"]; if (OnFacebookLogin(fbName)) { SaveSessionInDB(); Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", Session.SessionID)); Response.Cookies["ASP.NET_SessionId"].Domain = "." + WebConfig.TopLevelDomain; showDialog.Text = "false"; refreshPage.Text = "true"; } else { //user may not have account with this Facebook connection showDialog.Text = "true"; refreshPage.Text = "false"; } }
private void doFacebookConnect() { StateManager stateManager = StateManager.Instance; SessionValue objSessionvalue = (SessionValue)stateManager.Get("objSessionvalue", StateManager.State.Session); if (objSessionvalue == null) { messageText.Text = "Your Tribute session had expired. Please log in."; refreshPage.Text = Request.QueryString["source"].ToString().Equals("headerLogin") ? "false" : "true"; } else { UserRegistration objUserReg = new UserRegistration(); TributesPortal.BusinessEntities.Users objUsers = new TributesPortal.BusinessEntities.Users(); objUsers.UserId = objSessionvalue.UserId; objUsers.FacebookUid = _FacebookUid; objUserReg.Users = objUsers; UserInfoManager umgr = new UserInfoManager(); umgr.UpdateFacebookAssociation(objUserReg); StringBuilder sbr = new StringBuilder(); if (objUserReg.CustomError != null) { var fbwc = new FacebookWebClient(FacebookWebContext.Current.AccessToken); var me = (IDictionary<string, object>)fbwc.Get("me"); string fbName = (string)me["first_name"] + " " + (string)me["last_name"]; sbr.Append(string.Format("<div class=\"yt-Error\"><h3>Sorry, {0}.</h3>", fbName)); sbr.Append(string.Format( "The Facebook account named {0} is aleady used by some other Your Tribute Account.", fbName)); sbr.Append("Would you like to:"); sbr.Append("<ul>"); sbr.Append("<li><a href=\"#\" onclick=\"fb_logout(); return false;\">"); sbr.Append(" <img id=\"fb_logout_image\" "); sbr.Append("src=\"http://static.ak.fbcdn.net/images/fbconnect/logout-buttons/logout_small.gif\""); sbr.Append(" alt=\"Logout from Facebook and Your Tribute\"/></a> of both Your Tribute and Facebook Connect "); sbr.Append("and switch to the other account using your Facebook email address and password.</li>"); sbr.Append("<li><a href=\"#\" onclick=\"fb_err_logout(); return false;\">"); sbr.Append("<img id=\"fb_logout_image\" "); sbr.Append("src=\"http://static.ak.fbcdn.net/images/fbconnect/logout-buttons/logout_small.gif\""); sbr.Append(" alt=\"Disconnect from Facebook\"/></a> of Facebook Connect and try again.</li>"); sbr.Append("<li><a href=\"javascript:void(0);\" onclick=\"OpenContactUS();\">Contact us</a> to discuss the situation further if you are confused.</li>"); sbr.Append("</div>"); messageText.Text = sbr.ToString(); refreshPage.Text = "false"; } else { if(Request.QueryString["source"].ToString().Equals("headerLogin")) { refreshPage.Text = "true"; } else { messageText.Text = "<div class=\"yt-Notice\">Facebook Connection was added to your account.</div>"; refreshPage.Text = "false"; } } } }