YAFLogo

Posted by: jax - Saturday, 17 July 2010 16:57:22
Hi All, I'm currently working on enabling people to login to YAF with thier facbook account, I've got most of it working but I need a little help! 1. I am trying to set the timezone, culture and languagefile for users but I can't work out how to set this, can anyone help with this? 2. Saving a users avatar, any ideas? I have tried YAF.Classes.Data.DB.user_saveavatar(UserID, "http://graph.facebook.com/" & fbu.id & "/picture", Nothing, Nothing) but I get no error message and nothing is written to the DB. Once I've got this all sorted I'll post my code up here.

Posted by: bbobb - Saturday, 17 July 2010 17:54:29
[quote=jax] 1. I am trying to set the timezone, culture and languagefile for users but I can't work out how to set this, can anyone help with this?[/quote] Look for the user_save sp. [quote=jax] 2. Saving a users avatar, any ideas? I have tried YAF.Classes.Data.DB.user_saveavatar(UserID, "http://graph.facebook.com/" & fbu.id & "/picture", Nothing, Nothing) but I get no error message and nothing is written to the DB. [/quote] Look for Gravatar implementation - it can be helpful.

Posted by: Kamyar - Sunday, 18 July 2010 07:53:05
Very exciting idea. There are two stored procedures which have the responsibility to save language/culture and avatar. [quote]1. I am trying to set the timezone, culture and languagefile for users but I can't work out how to set this, can anyone help with this?[/quote]the user_save stored procedure as mentioned by bbobb. for an example see how it is called in controls/edituserprofile.ascx.cs line 329. [quote]2. Saving a users avatar, any ideas? I have tried YAF.Classes.Data.DB.user_saveavatar(UserID, "http://graph.facebook.com/" & fbu.id & "/picture", Nothing, Nothing) but I get no error message and nothing is written to the DB.[/quote]in controls/edituseravatar.ascx.cs line 262, the user_saveavatar is called similar to your call. First of all, check to see if you have enabled [b]"Allow Remote Avatars"[/b]. Do this in [b]Admin->Host Settings->Avatars[/b]. If you have checked it and no error is returned from your call, it is likely that the stored procedure is called properly. Try to catch any odd behavior from sp with SQL Server profiler.

Posted by: jax - Monday, 19 July 2010 17:08:55
OK Great, I'me calling both of thoose sp's like so: Dim fbu As New graph.fbuser(True) Dim Mu As MembershipUser = Membership.CreateUser(username, password, fbu.email, "Account set up from facebook, contact support.", "##############", True, Nothing) Dim up As YAF.Classes.Utils.YafUserProfile = YAF.Classes.Utils.YafUserProfile.GetProfile(username) up.Initialize(username, True) up.SetPropertyValue("facebookID", fbu.id) up.Save() ' setup inital roles (if any) for this user RoleMembershipHelper.SetupUserRoles(1, username) 'Set the Avatar Img Dim UserID As Integer = YAF.Classes.Data.DB.user_get(1, Mu.ProviderUserKey) YAF.Classes.Data.DB.user_saveavatar(CObj(UserID), CObj("http://graph.facebook.com/" & fbu.id & "/picture"), Nothing, Nothing) YAF.Classes.Data.DB.user_save(UserID, 1, username, username, Mu.Email, Convert.ToInt32(fbu.timezone), CObj("english.xml"), CObj(fbu.locale.Replace("_", "-")), Nothing, False, True, True, True, True, False) UserMembershipHelper.ClearCacheForUserId(UserID) The problem is that for some reason my userID is always 0 so obviously user_saveavatar and user_save fail, upon stepping through it seems the row has not yet been created in yaf_User for this user. I'm obviously missing something. Any Ideas?

Posted by: jax - Tuesday, 20 July 2010 11:31:50
Does anyone have any ideas on what I'm missing?

Posted by: jax - Tuesday, 20 July 2010 19:40:13
Fresh eye's fixed the issue! So I've got a very simple facebook login working with YAF providers. Which also allows you to access users FB profile info. At the moment this is done outside of yaf interacting with the YAF providers. I don't think it's solid yet, but I'm going to do some testing with some users as see what happens, once it looks like a solution I will post the code here. Cheers

Posted by: Kamyar - Tuesday, 20 July 2010 20:37:50
Thanks jax, I will appreciate it if you share the code once you think it's ready.

Posted by: jax - Tuesday, 20 July 2010 23:05:08
[quote=Kamyar]Thanks jax, I will appreciate it if you share the code once you think it's ready.[/quote] No problem, will be a few days before I start testing, so probably about a week I should think.

Posted by: 9key - Friday, 12 November 2010 23:45:29
Any updates? :?:

Posted by: doxa123 - Monday, 22 November 2010 09:08:06
Good news, thanks :) We are waiting for the released version...