
It turns out with Social Connected 3.0 that the data is stored in xDB facets, so the data isn't missing but is simply stored in a different location.
How to access those fields with Social Connected 3.0:
Get the facebook users
var users = Domain.GetDomain("extranet").GetUsers();
//filter for only facebook username ends with _facebook
List facebookUserList = new List();
foreach (Sitecore.Security.Accounts.User user in users)
{
string userName = user.Name;
if (!string.IsNullOrEmpty(userName) & userName.EndsWith("_facebook"))
{
facebookUserList.Add(user);
}
}
Get the facebook data
foreach( Sitecore.Security.Accounts.User facebookUser in facebookUserList){
if (facebookUser != null & facebookUser.Profile != null)
{
foreach (var customPropertyName in facebookUser.Profile.GetCustomPropertyNames())
{
if (customPropertyName.Contains("fb_"))
{
string stringToLog = string.Format("Profile Field:{0}:{1}:{2}", customPropertyName, facebookUser.Profile.GetCustomProperty(customPropertyName), lineBreak);
Sitecore.Diagnostics.Log.Info(stringToLog, this);
}
}
var socialProfileManager = ExecutingContext.Current.IoC.Get();
SocialProfile socialProfile = socialProfileManager.GetSocialProfile(facebookUser.Name, "Facebook"); //socialProfile.Fields property should contain all fields at this moment
foreach (string key in socialProfile.Fields.Keys)
{
string value = socialProfile.Fields[key];
string stringToLog = string.Format("Social Profile Field:{0}:{1}:{2}", key, value, lineBreak);
Sitecore.Diagnostics.Log.Info(stringToLog, this);
}
}
}
Comments
Post a Comment