In this post we will discuss how we can follow or unfollow people by using SharePoint 2013 client object model. Follow concept is a new feature in SharePoint 2013
Also you can check how to configure following settings in SharePoint 2013 here
Programmatically we can follow or unfollow people in SharePoint 2013. To work with .Net client object model we need to give reference to the below assemblies:
Here we will use SocialFollowingManager class.
Below is the full code:
ClientContext clientContext = new ClientContext("http://ServerURL");
SocialFollowingManager followingManager = new SocialFollowingManager(clientContext);
SocialActorInfo actorInfo = new SocialActorInfo();
actorInfo.AccountName = "domain\\username";
ClientResult<bool> isFollowed = followingManager.IsFollowed(actorInfo);
if (isFollowed == true)
//If the user already following you can stop following by calling the StopFollowing() method.
//If the user is not follwing then you can follow by using the Follow() method.