YAFLogo

jax
  • jax
  • 78.8% (Friendly)
  • YAF Lover Topic Starter
13 years ago
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.

Sponsor
bbobb
  • bbobb
  • 100% (Exalted)
  • YAF Developer
13 years ago

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?

jax wrote:

Look for the user_save sp.

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.

jax wrote:

Look for Gravatar implementation - it can be helpful.

Kamyar
  • Kamyar
  • 100% (Exalted)
  • YAF Developer
13 years ago
Very exciting idea.

There are two stored procedures which have the responsibility to save language/culture and avatar.

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?

the user_save stored procedure as mentioned by bbobb. for an example see how it is called in controls/edituserprofile.ascx.cs line 329.

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.

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 "Allow Remote Avatars". Do this in Admin->Host Settings->Avatars.

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.


If at first you don’t succeed, call it version 1.0
jax
  • jax
  • 78.8% (Friendly)
  • YAF Lover Topic Starter
13 years ago
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?

jax
  • jax
  • 78.8% (Friendly)
  • YAF Lover Topic Starter
13 years ago
Does anyone have any ideas on what I'm missing?
jax
  • jax
  • 78.8% (Friendly)
  • YAF Lover Topic Starter
13 years ago
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

Kamyar
  • Kamyar
  • 100% (Exalted)
  • YAF Developer
13 years ago
Thanks jax, I will appreciate it if you share the code once you think it's ready.
If at first you don’t succeed, call it version 1.0
jax
  • jax
  • 78.8% (Friendly)
  • YAF Lover Topic Starter
13 years ago

Thanks jax, I will appreciate it if you share the code once you think it's ready.

Kamyar wrote:

No problem, will be a few days before I start testing, so probably about a week I should think.

9key
  • 9key
  • 53% (Neutral)
  • YAF Forumling
13 years ago
Any updates? :?:
doxa123
  • doxa123
  • 100% (Exalted)
  • YAF All-the-Time YAF Version: 3.1.14
13 years ago
Good news, thanks 🙂 We are waiting for the released version...