FAQ |
Kalender |
![]() |
#12 | ||
|
|||
Nykomling
|
Upplever lite av ett problem nu.
Har testat lite olika javascript från Facebook Community. Saken är den att jag ser om inloggningsuppgifterna är korrekta i min MasterPage, därefter skapar jag sessioner osv. Men när facebook stänger popupen och fyller min <div id="user" /> med användarinfo (på klientsidan givetvis), och jag laddar om sidan, så är jag inte inloggad (på serversidan givetvis). Mitt javascript ser ut såhär: Kod:
FB_RequireFeatures(["XFBML"], function() { FB.init("9afc553810bcd6aeef3ecdbd72a8b48a", "http://Min-Domän.com/xd_receiver.htm"); FB.Facebook.get_sessionState().waitUntilReady(function() { FB.Connect.ifUserConnected(update_user_box); }); }); function update_user_box() { var user_box = J("#user"); user_box.append( "<span>" + "<fb:profile-pic uid='loggedinuser' facebook-logo='true'></fb:profile-pic>" + "Welcome <fb:name uid='loggedinuser'></fb:name>" + "You are signed in with your facebook account." + "</span>"); FB.XFBML.Host.parseDomTree(); } Jag läser av uppgifterna såhär: Kod:
FBConnectAuthentication auth = new FBConnectAuthentication(ConnectAuthentication.ApiKey, ConnectAuthentication.SecretKey); if (auth.Validate() != ValidationState.Valid) { //Response.Redirect("/Default.aspx"); // The request does not contain the details of a valid Facebook connect session - you'll probably want to throw an error here. } else if (!String.IsNullOrEmpty(Request.QueryString["session"])) { FBConnectSession fbSession = auth.GetSession(); string userId = fbSession.UserID; string sessionKey = fbSession.SessionKey; Facebook.Schema.user user = p.Api.Users.GetInfo(long.Parse(userId)); if (user != null) { var friends = p.Api.Friends.Get(long.Parse(userId)); string FirstName = user.first_name; string LastName = user.last_name; string ShortenLastName = string.Empty; string UsernameTry = string.Empty; UsernameTry = GenerateUserNameWithNumbers(FirstName); UsernameTry = UsernameTry.Trim(); if (LoginUser(userId)) { if (CurrentUser.IsFromFacebook) { if (!CurrentUser.IsFacebookEmailActivated) { Response.Redirect("/User/ActivateAccount.aspx"); } } } if (Celpocket.Profile.UserExists(userId)) { UsernameTry = GenerateUserNameWithNumbers(FirstName); } bllCreateAccount.CreateAccount(UsernameTry, userId, RandomPassword.Generate(10), FirstName, LastName, user.birthday_date); if (LoginUser(userId)) { if (CurrentUser.IsFromFacebook) { if (!CurrentUser.IsFacebookEmailActivated) { Response.Redirect("/User/ActivateAccount.aspx"); } } } } } Senast redigerad av peterbf den 2010-01-11 klockan 11:52 |
||
![]() |
![]() |
|
|