【问题标题】:Sitecore8 social connect does not import configured Facebook profile propertiesSitecore8 社交连接不导入配置的 Facebook 个人资料属性
【发布时间】:2015-03-03 15:49:08
【问题描述】:

根据这篇文章: http://techmusingz.wordpress.com/2014/07/03/social-connected-with-sitecore-facebook-2-access-facebook-information/ 我应该将 Sitecore.Social.ProfileMapping.Facebook.config 中配置的属性导入 SC 用户配置文件:

我得到的只是这些:

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

如何让其他属性填充?

【问题讨论】:

  • 我将在黑暗中试一试,因为我还没有机会调查 SiteCore 8 社交功能...指定的用户帐户是否完成了所有其他字段(例如如工作、教育等),因为其中一些字段是可选的。指定用户帐户的隐私设置是什么。它可能已将某些信息设置为仅对朋友而非所有人可用,等等。
  • 不幸的是,所有的检查。个人资料信息在那里,应该没有限制。

标签: sitecore sitecore-social-connected sitecore8


【解决方案1】:

从 3.0 版开始,Social Connected 将社交资料字段存储在 Sitecore xDB 联系人方面。这就是为什么您在用户配置文件中没有它们的原因。

要获取必填字段,您应该使用 Social Connected API。特别是,您应该使用 SocialProfileManager 类的 GetSocialProfile 方法来获取特定网络中用户的社交资料。然后,您将可以访问社交资料的 Fields 属性中的所有社交资料字段。示例:

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”]; 

【讨论】:

  • 您使用的是哪个版本的 Sitecore?我没有看到 ExecutingContext.Current.. 你在使用自己的 DI 容器吗?第二种方法返回一个没有字段的空配置文件。我已经检查了我的配置、安全等,但仍然没有运气。
  • 我正在使用 Sitecore Experience Platform 8 - Update 2。ExecutingContext.Current - 它是 Social Connected 的一部分,要使用它,您必须引用 Sitecore.Social.Infrastructure.dll 程序集。或者,您可以直接创建一个实例:new SocialProfileManager()
  • @Derek 我建议您检查 XDB 中是否存储了适当的社交资料。为此,您需要在“联系人”集合中找到适当的联系人,并检查是否存在具有适当网络元素的 SocialProfile 构面。
  • @VitaliiTylyk 即使我使用相同的代码,我也没有在字段中获得任何项目。我的个人资料映射配置也已更新,但仍然没有运气。您能否建议我可能错在哪里。
【解决方案2】:

我在 Sitecore 8 上遇到过同样的问题。 事实上,来自 facebook 的基本数据可通过 GetCustomProperty 函数获得,但其余的个人资料数据稍后会在 SocialProfileManager 下检索和提供。

要使此类可用,请记住在您的项目中引用 Sitecore.Social.Api.dll 和 Sitecore.Social.Domain.dll。

在那之后:

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
    }
}

【讨论】:

    猜你喜欢
    • 2017-10-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-21
    • 1970-01-01
    相关资源
    最近更新 更多