**WORK IN PROGRESS** golang API client for interacting with the jschan imageboard API.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

49 lines
1014 B

package main
import (
"context"
"fmt"
"jschan/app"
)
func main() {
jschanClient := jschan.NewClient("https://fatchan.org")
ctx := context.Background()
loginOptions := &jschan.PostLoginOptions{
Username: "",
Password: "",
Twofactor: "",
}
err := jschanClient.Login(ctx, loginOptions)
if err != nil {
fmt.Println(err)
//return
}
if jschanClient.SessionCookie != "" {
fmt.Printf("Logged in as user %s\n", loginOptions.Username)
}
overboardOptions := &jschan.GetOverboardOptions{
IncludeDefault: true,
}
res, err := jschanClient.GetOverboardCatalog(ctx, overboardOptions)
if err != nil {
fmt.Println(err)
return
}
fmt.Printf("Fetched overboard catalog with %d threads\n", len(res.Threads))
getCatalogOptions := &jschan.GetCatalogOptions{
Board: "t",
}
res2, err2 := jschanClient.GetCatalog(ctx, getCatalogOptions)
if err2 != nil {
fmt.Println(err2)
return
}
fmt.Printf("Fetched board %s catalog with %d threads\n", getCatalogOptions.Board, len(res2))
return
}