SharePoint 2013 开发——其他社交功能

简介: 博客地址:http://blog.csdn.net/FoxDave上一篇讲了如何获取用户配置文件的相关属性,它属于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;
            ClientResult<SocialFeed> 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;
            ClientResult<int> followedCount = followingManager.GetFollowedCount(SocialActorTypes.Users);
            ClientResult<SocialActor[]> followedResult = followingManager.GetFollowed(SocialActorTypes.Users);
            ClientResult<SocialActor[]> 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文档,写得还是很详细清晰的,如果我们在工作中遇到了相关内容的任务,能够提供很有力的参考和帮助。

相关文章
|
5月前
|
数据采集 自然语言处理 监控
基于.Net开发的、支持多平台、多语言餐厅点餐系统
基于.Net开发的、支持多平台、多语言餐厅点餐系统
76 0
|
UED Windows
Windows 11 发布 6 个月以来 UI / UX 设计仍不一致:媒体喊话微软“先做好基础功能”
Windows 11 发布 6 个月以来 UI / UX 设计仍不一致:媒体喊话微软“先做好基础功能”
106 0
Windows 11 发布 6 个月以来 UI / UX 设计仍不一致:媒体喊话微软“先做好基础功能”
|
存储 NoSQL 定位技术
SAP系统和微信集成的系列教程之三:微信用户关注公众号之后,自动在SAP C4C系统创建客户主数据
这是Jerry 2020年的第84篇文章,也是汪子熙公众号总共第266篇原创文章。
SAP系统和微信集成的系列教程之三:微信用户关注公众号之后,自动在SAP C4C系统创建客户主数据
|
存储 XML NoSQL
SAP系统和微信集成的系列教程之十:如何在SAP C4C系统里直接回复消息给微信用户
SAP系统和微信集成的系列教程之十:如何在SAP C4C系统里直接回复消息给微信用户
SAP系统和微信集成的系列教程之十:如何在SAP C4C系统里直接回复消息给微信用户
|
数据库 安全 数据安全/隐私保护