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

403 Forbidden #36

Open
Albinzr opened this issue Jul 14, 2022 · 1 comment
Open

403 Forbidden #36

Albinzr opened this issue Jul 14, 2022 · 1 comment

Comments

@Albinzr
Copy link

Albinzr commented Jul 14, 2022

When I tried, the bellow code i got 403 error, Can any one tell me why this is happening and how can I fix this issue?

        package main

        import (
	        "context"
	        "fmt"
        
	        "github.com/vartanbeno/go-reddit/v2/reddit"
        )
        
        func main() {
	        ctx := context.Background()
	        client, err := reddit.NewReadonlyClient()
        
	        if err != nil {
		        fmt.Println("Error from reddit.NewReadonlyClient()", err)
	        }
	        listOpts := &reddit.ListOptions{
		        Limit: 10, // always 100, so we can filter out without extra logic; if this is ever > 100, use resp.After
	        }
	        data, res, err := client.Subreddit.HotPosts(ctx, "AnimalsBeingBros", listOpts)
        
	        fmt.Println(data)
	        fmt.Println(res)
	        fmt.Println(err)
        
        }
@jancimertel
Copy link

jancimertel commented Aug 19, 2022

NewReadonlyClient being variadic, it accepts custom http client reference

Reddit api blocks the default http client configuration. Don't know when it started, but should be recently.

Edit: more here

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

2 participants