...
Source file
src/jschan/example.go
Documentation: jschan
1 package main
2
3 import (
4 "context"
5 "fmt"
6 "jschan/app"
7 )
8
9 func main() {
10
11 client := jschan.NewClient("http://dev-jschan.lan")
12 ctx := context.Background()
13
14 loginOptions := &jschan.PostLoginOptions{
15
16 Username: "admin",
17 Password: "wRbwo5lFNfGBjKqwIAHY94tshEQ=",
18 }
19 err := client.Login(ctx, loginOptions)
20 if err != nil {
21 fmt.Println(err)
22 return
23 }
24 if client.SessionCookie != "" {
25 fmt.Printf("Logged in as user %s\n", loginOptions.Username)
26 if _, err := client.GetCSRFToken(ctx); err != nil {
27 fmt.Println(err)
28 return
29 }
30 }
31
32 manageReportsOptions := &jschan.GetManageReportsOptions{
33 Page: 0,
34 IP: "10.0.0.192",
35 Board: "",
36 }
37 reports, err2 := client.GetManageReports(ctx, manageReportsOptions)
38 if err2 != nil {
39 fmt.Println(err2)
40 return
41 }
42 fmt.Printf("Fetched %d reports\n", len(reports.Reports))
43
44 }
45
View as plain text