厦门微网站建设公司,黑牛网站建设,咸阳市住房和城乡建设局网站,长沙房地产信息网官网博客地址#xff1a;http://blog.csdn.net/FoxDave上一篇讲了如何获取用户配置文件的相关属性#xff0c;它属于SharePoint 2013社交功能的一个小的构成部分。社交功能是SharePoint 2013改进的一大亮点。可以在现有网站上开启社交功能或者新建一个专门用于社交用途的社区网站… 博客地址http://blog.csdn.net/FoxDave上一篇讲了如何获取用户配置文件的相关属性它属于SharePoint 2013社交功能的一个小的构成部分。社交功能是SharePoint 2013改进的一大亮点。可以在现有网站上开启社交功能或者新建一个专门用于社交用途的社区网站社交功能包括关注人或内容、艾特、#等功能、有清晰的用户积分制度等等。由于工作中不会有太多关于这方面的开发需求并且个人觉得这部分做得挺不错基本的需求应该是够用了强大的或许就不在SharePoint上了所以本篇只会用两个小例子展示一下如何用客户端对象模型与SharePoint社交功能进行交互来说明SharePoint 2013社交功能的开发当然不仅限于客户端对象模型JSOM和REST也可以做类似的事情。包括之前提到的用户配置文件相关的开发在用客户端对象模型做社交相关功能的代码交互开发时需要引入Microsoft.SharePoint.Client、Microsoft.SharePoint.ClientRuntime和Microsoft.SharePoint.Client.UserProfiles这三个程序集并在代码文件头部增加如下两个引用using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.Social;首先构建上下文对象ClientContext clientContext new ClientContext(你的网站URL);
在Microsoft.SharePoint.Client.Social这个命名空间下有SocialFeedManager、SocialFeedOptions、SocialPostCreationData和SocialFollowingManager等对象模型可供我们使用分别跟订阅、回帖、关注等有关。获取指定用户的动态SocialFeedManager feedManager new SocialFeedManager(clientContext);SocialFeedOptions feedOptions new SocialFeedOptions();feedOptions.MaxThreadCount 10;ClientResultSocialFeed feed feedManager.GetFeedFor(指定的用户, feedOptions);clientContext.ExecuteQuery();for (int i 0; i feed.Value.Threads.Length; i){SocialThread thread feed.Value.Threads[i];string postText thread.RootPost.Text;Console.WriteLine(\t (i 1) . postText);}获得指定用户关注和被关注的人static void Main(string[] args){string serverUrl 你的网站URL;string targetUser 指定的用户;ClientContext clientContext new ClientContext(serverUrl);SocialFollowingManager followingManager new SocialFollowingManager(clientContext);SocialActorInfo actorInfo new SocialActorInfo();actorInfo.AccountName targetUser;ClientResultint followedCount followingManager.GetFollowedCount(SocialActorTypes.Users);ClientResultSocialActor[] followedResult followingManager.GetFollowed(SocialActorTypes.Users);ClientResultSocialActor[] followersResult followingManager.GetFollowers();clientContext.ExecuteQuery();Console.WriteLine(当前用户关注的人数: ({0}), followedCount.Value);IterateThroughPeople(followedResult.Value);Console.WriteLine(\n谁关注此用户:);IterateThroughPeople(followersResult.Value);Console.ReadKey();}static void IterateThroughPeople(SocialActor[] actors){foreach (SocialActor actor in actors){Console.WriteLine( - {0}, actor.Name);Console.WriteLine(\t链接: {0}, actor.PersonalSiteUri);Console.WriteLine(\t头像: {0}, actor.ImageUri);}}更多内容请参考微软MSDN文档写得还是很详细清晰的如果我们在工作中遇到了相关内容的任务能够提供很有力的参考和帮助。 转载于:https://www.cnblogs.com/justinliu/p/5961609.html