jax
  •  jax
  • 78.8% (Friendly)
  • YAF Lover Topic Starter
2010-07-17T14:57:22Z
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
2010-07-17T15:54:29Z
jax wrote:


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?


Look for the user_save sp.
jax wrote:


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.


Look for Gravatar implementation - it can be helpful.
Kamyar
2010-07-18T05:53:05Z
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?

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.

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.
Kamyar attached the following image(s):

If at first you don’t succeed, call it version 1.0
jax
  •  jax
  • 78.8% (Friendly)
  • YAF Lover Topic Starter
2010-07-19T15:08:55Z
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
2010-07-20T09:31:50Z
Does anyone have any ideas on what I'm missing?
jax
  •  jax
  • 78.8% (Friendly)
  • YAF Lover Topic Starter
2010-07-20T17:40:13Z
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
2010-07-20T18:37:50Z
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
2010-07-20T21:05:08Z
Kamyar wrote:

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



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
2010-11-12T22:45:29Z
Any updates? :?:
doxa
2010-11-22T08:08:06Z
Good news, thanks 🙂 We are waiting for the released version...
Running YAF.NET v2.0 Final at: https://blueway.app 

About Us

The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

Powered by Resharper Donate with PayPal button

Project Twitter Updates

Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved