Sitecore8 social connect does not import configured Facebook profile properties

647 views Asked by At

According to this article: http://techmusingz.wordpress.com/2014/07/03/social-connected-with-sitecore-facebook-2-access-facebook-information/ I should get the properties configured in Sitecore.Social.ProfileMapping.Facebook.config imported to the SC User Profile: enter image description here

All I get however are these:

fb_basicData_id: 100001964217563
fb_basicData_email: <hidden>@hotmail.com
fb_basicData_appKey: <hidden> 
fb_basicData_appSecret: <hidden> 
fb_basicData_accessTokenSecret: <hidden> 
fb_lastRenewed: 20150106T013821Z 
fb_fieldsLastRenewed: 20150105T234345Z

How do I get the other properties to populate?

2

There are 2 answers

4
Vitalii Tylyk On

Starting from version 3.0, Social Connected stores social profile fields in Sitecore xDB contact facets. This is why you don't have them in user profile.

To get the required fields, you should use Social Connected API. Particularly, you should use the GetSocialProfile method of the SocialProfileManager class to get social profile of a user in a specific network. And then you will have access to all social profile fields in the Fields property of the social profile. Example:

var socialProfileManager = ExecutingContext.Current.IoC.Get<ISocialProfileManager>(); // or create it directly: new SocialProfileManager();
var socialProfile = socialProfileManager.GetSocialProfile(“userName”, “Facebook”);
var facebookGender = socialProfile.Fields[“fb_gender”]; 
0
Daniel Costa On

I've struggled with the same issue on Sitecore 8. Indeed the basic data from facebook is available from the GetCustomProperty function, but the rest of the profile data is later retrieved & made available under the SocialProfileManager.

For this class to be available remember to reference the Sitecore.Social.Api.dll and Sitecore.Social.Domain.dll in your project.

After that f.e.:

string facebook_email = Sitecore.Context.User.Profile.GetCustomProperty("fb_basicData_email");
if (!String.IsNullOrEmpty(facebook_email))
{
    email.Text = facebook_email; // update UI here
}
var socialProfile = new SocialProfileManager();
// Do we have an extra profile from the user?
if (socialProfile.SocialProfileExists(user.Name, "Facebook"))
{
    var facebookProfile = socialProfile.GetSocialProfile(user.Name, "Facebook");
    if (facebookProfile.Fields["fb_first_name"] != null)
    {
        // do something here
    }
}