public IList <FacebookPost> FetchPostsFromFacebook() { string urlPattern = "https://graph.facebook.com/v2.9/{0}/feed?fields=reactions.limit(0).summary(true),type,caption,full_picture,icon,is_published,message,picture,updated_time,link,name,created_time,description,object_id,from,to&limit=50&access_token={1}"; string pageId = "154009054780458"; FacebookNewsContainer data = GetList <FacebookNewsContainer>(CreateAccessUrl(urlPattern, pageId)); return(new List <FacebookPost>( data.Data.Where(d => d.Reactions.Summary.TotalCount >= 10).Select(d => { string content = d.Message + "\n\n" + d.Name + "\n\n" + d.Link; return new FacebookPost { ExternalKey = d.ObjectId, CreateDate = d.CreatedDate, Content = content, Likes = d.Reactions.Summary.TotalCount, CreatorId = d.From.Id, Tags = FacebookPost.ExtractTags(content), LastUpdated = DateTime.Now }; }))); }
public void ProvidedContentShouldExtractTags(string content, string expectedTagsCommaSeparated) { var actaulTags = String.Join(",", FacebookPost.ExtractTags(content)); Assert.Equal(expectedTagsCommaSeparated, actaulTags); }