Update readme
Signed-off-by: Vartan Benohanian <vartanbeno@gmail.com>
This commit is contained in:
parent
b79488e994
commit
49fdcfead5
1 changed files with 8 additions and 5 deletions
13
README.md
13
README.md
|
@ -31,15 +31,18 @@ package main
|
||||||
import "github.com/vartanbeno/go-reddit/reddit"
|
import "github.com/vartanbeno/go-reddit/reddit"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
withCredentials := reddit.WithCredentials("id", "secret", "username", "password")
|
credentials := &reddit.Credentials{
|
||||||
client, _ := reddit.NewClient(nil, withCredentials)
|
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 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
|
## Examples
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
|
@ -66,7 +69,7 @@ if err != nil {
|
||||||
<summary>Get r/golang's top 5 posts of all time.</summary>
|
<summary>Get r/golang's top 5 posts of all time.</summary>
|
||||||
|
|
||||||
```go
|
```go
|
||||||
result, _, err := client.Subreddit.Top(context.Background(), "golang", &reddit.ListPostOptions{
|
result, _, err := client.Subreddit.TopPosts(context.Background(), "golang", &reddit.ListPostOptions{
|
||||||
ListOptions: reddit.ListOptions{
|
ListOptions: reddit.ListOptions{
|
||||||
Limit: 5,
|
Limit: 5,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue