A Big boost for social features in SharePoint 2013 which were an extension for the features introduced in SharePoint 2010. In SharePoint 2013 Collaborating and exchanging information options have been improved a lot, Features like Micro Blogging, Community sites and sharing introduced in SharePoint 2013. The out of the box SharePoint 2013 social features can be read here and this post outlines the different ways to interact with social data API in SharePoint 2013. The new Social namespace contains API for interacting with feeds, posts and people.
Microsoft.SharePoint.Client.Social namespace can be used in .NET Client Object model, SP.Social in JavaScript object model and Microsoft.Office.Server.Social namespace in Server Object Model for working with the Social Data.
Retrieving the Social Feed for all users
Getfeed Method in SocialFeedManager class allows you to retrieve Social Feed for all users
Getfeed method returns the results as collection of threads, Iterating over the retrieved feed can be performed using the below code
The possible values for SocialFeedType enum and SocialThreadAttributes are shown below
You can call GetAlllikers method on FeedManager class to retrieve all liker information on particular post
Creating and publishing the posts to Social feed data as follows
Different dataitem types that you can include in a post are
Mentioning someone in post
Define the mention that you want to include in the post using SocialDataItem class as below
Adding the defined mention to post
Create a post and put a place holder for including mention and add the mention to post content items using the below code snippet
Publishing a post with tag
Including a tag in a post is similar to mentioning someone in the post, You have to create the tag first using SocialDataItem class and then specify the SocialDataItemType
Adding the tag to a new post requires place holder, if the tag is new then it adds to the server tag collection
Following people, sites and posts is an another important feature in SharePoint 2013 Social Features. When you follow a document or person then your activity shown up in the news feed which is a mysite feature in SharePoint 2013.
Following people in SharePoint 2013
In order to follow people in SharePoint 2013, Create an instance to SocialFollowingManager and pass the client context value as parameter and then define the Social Actor information that you want to follow
Check whether you are already following the target user and if not then call follow method on FollowingManager class
If you want to stop following a particular user then you can write the below code
Getting the list of people who are following you by creating an instance to the SocialFollowingManager class and then call the method GetFollowers as shown below
To display the list of people who the current user is following, call the GetFollowed method on SocialFollowingManager class.
Getting User Profile Property values
User Profile property information is about SharePoint user which includes display name, E-mail address, title and other personal information. Using Client-Object model you can only read the user profile but can not update. To update the user profile properties then you have to use server object model methods.
Create an instance to PeopleManager class and pass the clientcontext as a parameter then call the GetPropertiesFor method on it.
You can iterate over result and can display each user profile property values as below
Conclusion
This post explained different ways to interact with SharePoint 2013 social data using Client Object Model. The important features like retrieving the feed content, creating a post , mentioning and tagging, following people and retrieving the user profile properties explained with examples. The above code snippets can be used to customize the out of the box social data features in SharePoint 2013.
I want to create post with multiple mention users…so how i can do that…plz help me out…..