Muokkaa

Jaa


Follow people in SharePoint

Learn about common programming tasks for following people in SharePoint.

APIs for following people in SharePoint

When a user follows people in SharePoint, microblog posts that the people publish and notifications about their activities show up in the user's newsfeed. The features related to following people can be seen on the Newsfeed and People I'm following pages.

SharePoint provides the following APIs that you can use to programmatically follow people:

  • Client object models for managed code

    • .NET client object model

    • Silverlight client object model

    • Mobile client object model

  • JavaScript object model

  • Representational State Transfer (REST) service

  • Server object model

As a best practice in SharePoint development, use client APIs when you can. Client APIs include the client object models, a JavaScript object model, and a REST service. For more information about the APIs in SharePoint and when to use them, see Choose the right API set in SharePoint.

Each API includes a manager object that you use to perform core tasks for following people.

Note

The same APIs are used to follow content. See Follow content in SharePoint for an overview of Following Content tasks.

Table 1 shows the manager and other key objects (or REST resources) in the APIs and the class library (or access point) where you can find them.

Note

The Silverlight and mobile client object models are not explicitly included in Table 1 or Table 2 because they provide the same core functionality as the .NET client object model and use the same signatures. The Silverlight client object model is defined in Microsoft.SharePoint.Client.UserProfiles.Silverlight.dll, and the mobile client object model is defined in Microsoft.SharePoint.Client.UserProfiles.Phone.dll.

Table 1. SharePoint APIs used for following people programmatically

API Key objects
.NET client object model
See: How to: Follow people by using the .NET client object model in SharePoint
Manager object: SocialFollowingManager
Primary namespace: Microsoft.SharePoint.Client.Social
Other key objects: SocialActor , SocialActorInfo , SocialActorType , SocialActorTypes
Class library: Microsoft.SharePoint.Client.UserProfiles.dll
JavaScript object model
See: How to: Follow people by using the JavaScript object model in SharePoint
Manager object: SocialFollowingManager
Primary namespace: SP.Social
Other key objects: SocialActor, SocialActorInfo, SocialActorType, SocialActorTypes
Class library: SP.UserProfiles.js
REST service
See: Following people and content REST API reference for SharePoint
Manager resource: social.following
Endpoint URI: <siteUri>/_api/social.following
Primary namespace (OData.md): sp.social.SocialRestFollowingManager
Other key resources: SocialActor, SocialActorInfo, SocialActorType, SocialActorTypes
Server object model Manager object: SPSocialFollowingManager
Primary namespace: Microsoft.Office.Server.Social
Other key objects: SPSocialActor , SPSocialActorInfo , SPSocialActorType , SPSocialActorTypes
Class library: Microsoft.Office.Server.UserProfiles.dll

Common programming tasks for following people in SharePoint

Table 2 shows common programming tasks for following people and the members that you use to perform them. Members are from the .NET client object model (CSOM), JavaScript object model (JSOM), REST service, and server object model (SSOM).

Note

The same APIs are used to follow content. See Follow content in SharePoint for an overview of Following Content tasks.

The SocialFollowingManager object consolidates the core Following People and Following Content functionality for the current user. However, the PeopleManager object (see Table 3) provides some functionality that SocialFollowingManager does not provide, including methods to obtain the Following People status of other users.

Table 2. API for common tasks for following people by using the SocialFollowingManager object

Task Members
Create an instance of a manager object in the context of the current user CSOM: SocialFollowingManager
JSOM: SocialFollowingManager
REST: <siteUri>/_api/social.following
SSOM: SPSocialFollowingManager
Create an instance of a manager object in the context of a particular user CSOM: not implemented
JSOM: not implemented
REST: not implemented
SSOM: SPSocialFollowingManager (overloaded)
Have the current user start following (stop following) someone CSOM: Follow ( StopFollowing )
JSOM: follow ( stopFollowing)
REST: POST <siteUri>/_api/social.following/Follow (<siteUri>/_api/social.following/StopFollowing) and pass the actor parameter in the request body
SSOM: Follow ( StopFollowing )
Find out whether the current user is following a particular user CSOM: IsFollowed
JSOM: isFollowed
REST: POST <siteUri>/_api/social.following/my/IsFollowed and pass the actor parameter in the request body
SSOM: IsFollowed
Get the people who are following the current user CSOM: GetFollowers
JSOM: getFollowers
REST: GET <siteUri>/_api/social.following/my/Followers
SSOM: GetFollowers
Get the people who the current user is following CSOM: GetFollowed
JSOM: getFollowed
REST: GET <siteUri>/_api/social.following/my/Followed(types=1)
SSOM: GetFollowed
Get the count of people who the current user is following CSOM: GetFollowedCount
JSOM: getFollowedCount
REST: GET <siteUri>/_api/social.following/my/FollowedCount(types=1)
SSOM: GetFollowedCount
Get the people who the current user might want to follow CSOM: GetSuggestions
JSOM: getSuggestions
REST: GET <siteUri>/_api/social.following/my/Suggestions
SSOM: GetSuggestions

Table 3 shows the PeopleManager members that you can use for additional Following People functionality.

Table 3. API for common tasks for following people by using the PeopleManager object

Task Members
Find out whether the People I'm Following list for the current user is public CSOM: IsMyPeopleListPublic
JSOM: isMyPeopleListPublic
REST: IsMyPeopleListPublic
Example: GET <siteUri>/_api/SP.UserProfiles.PeopleManager/IsMyPeopleListPublic
SSOM: IsMyPeopleListPublic
Find out whether someone is following the current user CSOM: AmIFollowedBy
JSOM: amIFollowedBy
REST: AmIFollowedBy
Example: GET <siteUri>/_api/SP.UserProfiles.PeopleManager/AmIFollowedBy(accountName=@v)?@v='domain\\user'
SSOM: AmIFollowedBy
Get the people who a particular user is following CSOM: GetPeopleFollowedBy
JSOM: getPeopleFollowedBy
REST: GetPeopleFollowedBy
Example: GET <siteUri>/_api/SP.UserProfiles.PeopleManager/GetPeopleFollowedBy(accountName=@v)?@v='domain\\user'
SSOM: GetPeopleFollowedBy
Get the people who are following a particular user CSOM: GetFollowersFor
JSOM: getFollowersFor
REST: GetFollowersFor
Example: GET <siteUri>/_api/SP.UserProfiles.PeopleManager/GetFollowersFor(accountName=@v)?@v='domain\\user'
SSOM: GetFollowersFor
Find out whether a particular user is following another user CSOM: IsFollowing
JSOM: isFollowing
REST: IsFollowing (static)
Example: GET <siteUri>/_api/SP_UserProfiles_PeopleManager_IsFollowing(possibleFollowerAccountName=@v,possibleFolloweeAccountName=@y)?@v='domain\\user'&amp;@y='domain\\user'
SSOM: IsFollowing

How People Suggestions works on SharePoint Online

Results for People Suggestions are based on established Following People activity. Suggestions are offered when a user is following someone who has a mutual following with someone else who the user is not already following.

Following-related information is indexed during search crawls. After a crawl is complete, search analytics must then analyze the crawled Following information and output user suggestions. By default, search analytics runs once per day.

When a user opens the People I'm following page, the PeopleManager.GetMySuggestions() method is called. GetMySuggestions searches for new suggestions for the current user, updates the user's suggestions in the database, and presents the suggestions on the page.

See also