Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public IEnumerable GetWordPressPosts()
{
using(WebClient webClient = new WebClient())
{
string blogUrl = @ "https://public-api.wordpress.com/rest/v1.1/sites/hendrikbulens.wordpress.com/posts/";
string response = webClient.DownloadString(blogUrl);
WordPressBlog blogPosts = JsonConvert.DeserializeObject(response);
IEnumerable posts = blogPosts.posts.OrderByDescending(x => x.date).Take(3).Select(x => new BlogPost() {
Title = x.title,
Message = x.excerpt.CharacterLimit(150),
PublishedOn = x.date,
Comments = x.discussion.comment_count,
Link = x.URL
});
return posts;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.