Skip to content

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

Description

@JanssonTheBest

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


}

}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions