Reddit.NET
Reddit.NET copied to clipboard
Reddit.Exceptions.RedditForbiddenException: 'Reddit API returned Forbidden (403) response.'
I'm using the right AppID, as well as the correct secret code, but still, I get this
Reddit.Exceptions.RedditForbiddenException: 'Reddit API returned Forbidden (403) response.'
I'm trying to access posts on a subreddit.
the code:
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net.Http; using Reddit; using Reddit.Controllers; using Reddit.Things;
namespace CashCowByJansson { public class RedditStorieScrapper { public string Seceret { get; set; } public string AppID { get; set; } public string Storries { get; set; } public string Story { get; set; } public RedditStorieScrapper(string seceret, string appID) { Storries = File.ReadAllText("..\..\Buffer\StoriesHistory.txt"); Seceret = seceret; AppID = appID; Story = RetrievePost(); }
public string RetrievePost()
{
RedditClient redditClient = new RedditClient(appId: AppID, appSecret: Seceret);
var subReddit = redditClient.Subreddit("nosleep");
List<Reddit.Controllers.Post> posts = subReddit.Posts.GetHot(limit: 100).ToList();
foreach (var post in posts)
{
if (!Storries.Contains(post.ToString()))
{
return post.ToString();
}
}
return "";
}
}
}