~thrrgilag/woodstock

woodstock/examples/stream.go -rw-r--r-- 505 bytes
62b10b5cMorgan McMillian Update for new project location and module name 5 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package main

import (
	"fmt"

	"mcmillian.dev/go/woodstock"
)

const (
	CLIENT_ID     = "client id"
	CLIENT_SECRET = "client secret"
	ACCESS_TOKEN  = "access token"
)

func main() {
	client := woodstock.NewClient(CLIENT_ID, CLIENT_SECRET)
	client.SetAccessToken(ACCESS_TOKEN)
	result, err := client.GlobalStream()
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println("====")
	for _, post := range result.Data {
		fmt.Println(post.User.Username, ":", post.Content.Text)
		fmt.Println("====")
	}
}