Skip to content

Latest commit

 

History

History
45 lines (28 loc) · 1019 Bytes

Retrieve Posts From rall.md

File metadata and controls

45 lines (28 loc) · 1019 Bytes

Retrieve Posts From r/all

Author

Kris Craig

Required libraries

Overview

Retrieves the latest posts from r/all and groups them by subreddit.

Warning: Never call the About() method on a Subreddit instance for a reserved subreddit like r/all or r/popular. Doing so will throw an exception because they're not actual subreddits.

Library Installation

In the NuGet Package Manager console:

Install-Package Reddit

The Code

using Reddit;

...

var reddit = new RedditClient("YourRedditAppID", "YourBotUserRefreshToken");

IDictionary<string, IList<Post>> Posts = new Dictionary<string, IList<Post>>();
foreach (Post post in reddit.Subreddit("all").Posts.New)
{
	if (!Posts.ContainsKey(post.Subreddit))
	{
		Posts.Add(post.Subreddit, new List<Post>());
	}
	Posts[post.Subreddit].Add(post);
}

Source File

Retrieve Posts From rall.cs