SharePoint 2013 obtains user and user attention information
1. The person who follows the application
Static void getfollowedusers (string username, string siteurl)
{
Using (spsite site = new spsite (siteurl ))
{
Spservicecontextcontext = spservicecontext. getcontext (SITE );
Userprofilemanagerprofilemanager = new userprofilemanager (context );
If (profilemanager. userexists (username ))
{
Userprofileuserprofile = profilemanager. getuserprofile (username );
Spsocialfeedmanagerfeedmanager = new spsocialfeedmanager (USERPROFILE, context );
Spsocialfollowingmanagerfollowingmanager = new spsocialfollowingmanager (USERPROFILE, context );
Spsocialactor [] followed = followingmanager. getfollowed (spsocialactortypes. users );
Console. writeline ("followng :");
Foreach (VAR actor in followed)
{
Console. writeline (actor. accountname );
}
}
Else
{
Console. writeline (string. Format ("USERPROFILE for user {0} does not exist", username ));
}
}
}
2. Get the user's attention information:
Static void getfollower (string siteurl, string username)
{
Using (spsite site = new spsite (siteurl ))
{
Spservicecontextcontext = spservicecontext. getcontext (SITE );
Userprofilemanagerprofilemanager = new userprofilemanager (context );
If (profilemanager. userexists (username ))
{
Userprofileuserprofile = profilemanager. getuserprofile (username );
Spsocialfeedmanagerfeedmanager = new spsocialfeedmanager (USERPROFILE, context );
Spsocialfollowingmanagerfollowingmanager = new spsocialfollowingmanager (USERPROFILE, context );
Spsocialactor [] followers = followingmanager. getfollowers ();
Foreach (VAR actor in followers)
{
Console. writeline (actor. accountname );
}
}
Else
{
Console. writeline (string. Format ("USERPROFILE for user {0} does not exist", username ));
}
}
}
SharePoint 2013 obtains user and user attention information