2020-07-31 11:29:08 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2021-01-22 21:47:22 +00:00
|
|
|
"context"
|
2020-07-31 11:29:08 +00:00
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
// This is not a real token. Please find yours by logging
|
|
|
|
// into the GroupMe development website: https://dev.groupme.com/
|
|
|
|
const authorizationToken = "0123456789ABCDEF"
|
|
|
|
|
|
|
|
// A short program that gets the gets the first 5 groups
|
|
|
|
// the user is part of, and then the first 10 messages of
|
|
|
|
// the first group in that list
|
|
|
|
func main() {
|
|
|
|
// Create a new client with your auth token
|
|
|
|
client := groupme.NewClient(authorizationToken)
|
|
|
|
|
|
|
|
// Get the groups your user is part of
|
2021-01-22 21:47:22 +00:00
|
|
|
groups, err := client.IndexGroups(
|
|
|
|
context.Background(),
|
|
|
|
&groupme.GroupsQuery{
|
|
|
|
Page: 0,
|
|
|
|
PerPage: 5,
|
|
|
|
Omit: "memberships",
|
|
|
|
},
|
|
|
|
)
|
2020-07-31 11:29:08 +00:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Println(groups)
|
|
|
|
|
|
|
|
// Get first 10 messages of the first group
|
2021-01-22 21:47:22 +00:00
|
|
|
if len(groups) == 0 {
|
2020-07-31 11:29:08 +00:00
|
|
|
fmt.Println("No groups")
|
|
|
|
}
|
|
|
|
|
2021-01-22 21:47:22 +00:00
|
|
|
messages, err := client.IndexMessages(context.Background(), groups[0].ID, &groupme.IndexMessagesQuery{
|
2020-07-31 11:29:08 +00:00
|
|
|
Limit: 10,
|
|
|
|
})
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Println(messages)
|
|
|
|
}
|