Add ExamplePagination

pull/58/head
178inaba 2017-05-14 04:40:19 +09:00
parent f279adb618
commit b1d2d6719f
1 changed files with 25 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import (
"context"
"fmt"
"log"
"time"
"github.com/mattn/go-mastodon"
)
@ -40,3 +41,27 @@ func ExampleClient() {
fmt.Println(timeline[i])
}
}
func ExamplePagination() {
c := mastodon.NewClient(&mastodon.Config{
Server: "https://mstdn.jp",
ClientID: "client-id",
ClientSecret: "client-secret",
})
var followers []*mastodon.Account
var pg mastodon.Pagination
for {
fs, err := c.GetAccountFollowers(context.Background(), 1, &pg)
if err != nil {
log.Fatal(err)
}
followers = append(followers, fs...)
if pg.MaxID == 0 {
break
}
time.Sleep(10 * time.Second)
}
for _, f := range followers {
fmt.Println(f.Acct)
}
}