I'm quite desperate, I working on project when I'd like to impersotane users and create post on behalf of them, read theirs feeds and according of those do some actions. I have figured out how to post on another user newsfeed, but still cannot read all. I have tried function GetFeedFor(), but this give you back just threads, no likes, no follows. I have been trying impersonate the process accordingly:
using (SPSite site = new SPSite(myHostUrl)) { SPUser userForContext = site.RootWeb.SiteUsers[account2]; SPUserToken userToken = userForContext.UserToken; //create service context SPServiceContext serviceContext = SPServiceContext.GetContext(site); //using Service Context Scope using (new SPServiceContextScope(serviceContext)) { //create profile manager for loading my test accounts UserProfileManager profileManager = new UserProfileManager(serviceContext); UserProfile userProfile = profileManager.GetUserProfile(account2); /*List all NewsFeeds*/ SPSocialFeedManager feedManager = new SPSocialFeedManager(userProfile, serviceContext, userToken); //here is exception thrown away SPSocialFeed feed = feedManager.GetFeed(SPSocialFeedType.Personal, new SPSocialFeedOptions()); //this write post on user's newsfeed and works! WritePost(feedManager, "Forth Test!"); } }
Whole stack is here:
Microsoft.Office.Server.Social.SPSocialException was unhandled HResult=6 Message=The operation failed because an internal error occurred. Internal type name: Microsoft.Office.Server.Microfeed.MicrofeedException. Internal error code: 58. Source=Microsoft.Office.Server.UserProfiles ErrorCode=6 InternalErrorCode=58 InternalMessage=ServerErrorSecurityTrimmer : No Security Trimmer found : Correlation ID:00000000-0000-0000-0000-000000000000 : Date and Time : 13/09/2013 16:44:27 InternalStackTrace= at Microsoft.Office.Server.Microfeed.MicroBlogEntity.SecurityTrimMicroFeed(List`1 mbThreads, SPMicrofeedRetrievalOptions retrievalOptions) at Microsoft.Office.Server.Microfeed.SPMicrofeedThreadCollection.SecurityTrimMicroFeed(SPMicrofeedRetrievalOptions retrievalOptions) at Microsoft.Office.Server.Microfeed.SPMicrofeedThreadCollection.Populate(SPMicrofeedRetrievalOptions retrievalOptions, SPMicrofeedContext context) at Microsoft.Office.Server.Microfeed.SPMicrofeedManager.CommonGetFeedFor(SPMicrofeedRetrievalOptions retrievalOptions) at Microsoft.Office.Server.Microfeed.SPMicrofeedManager.CommonPubFeedGetter(SPMicrofeedRetrievalOptions feedOptions, MicrofeedPublishedFeedType feedType, Boolean publicView) at Microsoft.Office.Server.Microfeed.SPMicrofeedManager.GetMyPublishedFeed(SPMicrofeedRetrievalOptions feedOptions, MicrofeedPublishedFeedType typeOfPubFeed, Boolean ShowPublicView) at Microsoft.Office.Server.Social.SPSocialFeedManager.Microsoft.Office.Server.Social.ISocialFeedManagerProxy.ProxyGetFeed(SPSocialFeedType type, SPSocialFeedOptions options) at Microsoft.Office.Server.Social.SPSocialFeedManager.c__DisplayClass2b.b__2a(ISocialFeedManagerProxy proxy) at Microsoft.Office.Server.Social.SPSocialFeedManager.c__DisplayClass4b`1.b__4a() at Microsoft.Office.Server.Social.SPSocialUtil.InvokeWithExceptionTranslation[T](ISocialOperationManager target, String name, Func`1 func) InternalTypeName=Microsoft.Office.Server.Microfeed.MicrofeedException StackTrace: at Microsoft.Office.Server.Social.SPSocialUtil.TryTranslateExceptionAndThrow(Exception exception) at Microsoft.Office.Server.Social.SPSocialUtil.InvokeWithExceptionTranslation[T](ISocialOperationManager target, String name, Func`1 func) at Microsoft.Office.Server.Social.SPSocialFeedManager.S2SInvoke[T](String name, SPS2SAppExecutionContextBase context, Func`2 func, Boolean elevateForIsLocalCheck) at Microsoft.Office.Server.Social.SPSocialFeedManager.c__DisplayClass48`1.b__47() at Microsoft.Office.Server.Social.SPSocialUtil.InvokeWithExceptionTranslation[T](ISocialOperationManager target, String name, Func`1 func) at Microsoft.Office.Server.Social.SPSocialFeedManager.S2SInvoke[T](String name, MicroBlogEntity mbeTarget, Func`2 func, Boolean elevateForIsLocalCheck) at Microsoft.Office.Server.Social.SPSocialFeedManager.GetFeed(SPSocialFeedType type, SPSocialFeedOptions options) at SocialTest.CreatePost.Program.Main(String[] args) in c:\Users\m.bodocky\Documents\Visual Studio 2012\Projects\SocialTest\SocialTest.CreatePost\Program.cs:line 54 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException:
Thank you for any advice!