Merge pull request #46 from suzukaze/fix-usage-code-in-readme.md
Fix usage code in READMEpull/47/head
commit
e2631e1815
28
README.md
28
README.md
|
@ -8,18 +8,32 @@
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```go
|
```go
|
||||||
c := mastodon.NewClient(&mastodon.Config{
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"github.com/mattn/go-mastodon"
|
||||||
|
"log"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
c := mastodon.NewClient(&mastodon.Config{
|
||||||
Server: "https://mstdn.jp",
|
Server: "https://mstdn.jp",
|
||||||
ClientID: "client-id",
|
ClientID: "client-id",
|
||||||
ClientSecret: "client-secret",
|
ClientSecret: "client-secret",
|
||||||
})
|
})
|
||||||
err := c.Authenticate("your-username", "your-password")
|
err := c.Authenticate(context.Background(), "your-email", "your-password")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
timeline, err := c.GetTimelineHome(context.Background())
|
timeline, err := c.GetTimelineHome(context.Background())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
for i := len(timeline) - 1; i >= 0; i-- {
|
||||||
|
fmt.Println(timeline[i])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
## Status of implementations
|
## Status of implementations
|
||||||
|
|
Loading…
Reference in New Issue