Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reddit.Exceptions.RedditForbiddenException: 'Reddit API returned Forbidden (403) response.' #180

Open
JanssonTheBest opened this issue Jul 17, 2023 · 0 comments

Comments

@JanssonTheBest
Copy link

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 "";
    }


}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant