0

I've created a subsite based upon the "Collaboration/Project Site" template.

This template creates a newsfeed content of type MicroFeed.

I would like to use CSOM to extract the content of the posts entered in the Microfeed.

I've tried using both the Microsoft.SharePoint.Client.Microfeed and Microsoft.Sharepoint.Client.Social feed managers to retrieve the posts with no success.

Here's a version of the code that I've tried with the Microfeed namespace

var ctx = new ClientContext(@"https://somewhere.sharepoint.com/projects/test");
SecureString passWord = new SecureString();

foreach (char c in "pwd".ToCharArray()) passWord.AppendChar(c);

ctx.Credentials = new SharePointOnlineCredentials("emailAddr", passWord);

var mf = new MicrofeedManager(ctx);
ctx.Load(mf);
ctx.ExecuteQuery();

var threads = mf.GetMyConsolidatedFeed(new MicrofeedRetrievalOptions());
ctx.ExecuteQuery();

but the threads count is always 0.

The doc's that I've found so far are really sketchy.

Can anyone point me in the right direction?

0

Finally found the answer halfway down the page at http://msdn.microsoft.com/en-us/library/office/jj163237(v=office.15).aspx (Work with social feeds in SharePoint 2013).

The key to the google-fu was "Site Feed" as in

"Get the site feed for a team site" and "Publish a post to a site feed"

Instead of MicrofeedManager, use SocialFeedManager and specify the site feed as the 'actor'

var ctx = new ClientContext(@"https://somewhere.sharepoint.com/projects/test");
SecureString passWord = new SecureString();

foreach (char c in "pwd".ToCharArray()) passWord.AppendChar(c);

ctx.Credentials = new SharePointOnlineCredentials("emailAddr", passWord);

var sf = new SocialFeedManager(ctx);
ctx.Load(sf);
ctx.ExecuteQuery();


//to read from site feed
var f = sf.GetFeedFor("https://somewhere.sharepoint.com/projects/test/newsfeed.aspx", new SocialFeedOptions());
ctx.ExecuteQuery();
var cnt = f.Value.Threads.Count();

//to post to site feed
var result =sf.CreatePost("https://somewhere.sharepoint.com/projects/test/newsfeed.aspx", new SocialPostCreationData() { ContentText = "This should post to the write place" });
ctx.ExecuteQuery();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.