Update readme

Signed-off-by: Vartan Benohanian <vartanbeno@gmail.com>
This commit is contained in:
Vartan Benohanian 2020-08-25 20:55:32 -04:00
parent b79488e994
commit 49fdcfead5

View file

@ -31,15 +31,18 @@ package main
import "github.com/vartanbeno/go-reddit/reddit"
func main() {
withCredentials := reddit.WithCredentials("id", "secret", "username", "password")
client, _ := reddit.NewClient(nil, withCredentials)
credentials := &reddit.Credentials{
ID: "id",
Secret: "secret",
Username: "username",
Password: "password",
}
client, _ := reddit.NewClient(nil, credentials)
}
```
The first argument (the one set to `nil`) is of type `*http.Client`. It will be used to make the requests. If nil, it will be set to `&http.Client{}`.
The `WithCredentials` option sets the credentials used to make requests to the Reddit API.
## Examples
<details>
@ -66,7 +69,7 @@ if err != nil {
<summary>Get r/golang's top 5 posts of all time.</summary>
```go
result, _, err := client.Subreddit.Top(context.Background(), "golang", &reddit.ListPostOptions{
result, _, err := client.Subreddit.TopPosts(context.Background(), "golang", &reddit.ListPostOptions{
ListOptions: reddit.ListOptions{
Limit: 5,
},