Api calls

This commit is contained in:
Jannover5000r 2025-06-16 13:39:35 +02:00
parent cf6f7ed843
commit ca1d1383d7
4 changed files with 51 additions and 36 deletions

View file

@ -1,20 +1,56 @@
package Untis
import (
"bytes"
"encoding/json"
"log"
"net/http"
"os"
)
func Run() {
log.Println("Run")
type res struct {
Name string
url string
key int
type Params struct {
Users string `json:"users"`
Password string `json:"key"`
Client string `json:"client"`
}
/* r := res{"Jannik", "google.com", 4}
r, err := json.Marshal(r)
type Login struct {
Id string `json:"id"`
Method string `json:"method"`
Params Params `json:"params"`
Jsonrpc string `json:"jsonrpc"`
}
type LoginResponse struct {
result struct {
ID string `json:"sessionId"`
PersonType string `json:"personType"`
PersonId string `json:"personId"`
KlasseId string `json:"klasseId"`
}
}
var Url = "https://thalia.webuntis.com/WebUntis/jsonrpc.do?school=Mons_Tabor"
var Password = os.Getenv("UNTIS_PASSWORD")
var USERS = os.Getenv("UNTIS_USER")
func Auth() {
l := Login{"2023-05-06 15:44:22.215292", "authenticate", Params{os.Getenv("UNTIS_USER"), os.Getenv("UNTIS_PASSWORD"), "WebUntis Test"}, "2.0"}
loginJSON, err := json.Marshal(l)
login := bytes.NewReader(loginJSON)
if err != nil {
log.Printf("Error marshalling JSON: %v", err)
log.Fatalf("Error marshaling login data: %v", err)
return
} */
}
log.Println("Run")
res, err := http.Post(Url, "application/json", login)
if err != nil {
log.Printf("Error during authentication: %v", err)
return
}
log.Println(res)
log.Println("")
}

11
go.mod
View file

@ -2,13 +2,4 @@ module untislogger
go 1.24.4
require (
github.com/bwmarrin/discordgo v0.29.0
github.com/joho/godotenv v1.5.1
)
require (
github.com/gorilla/websocket v1.4.2 // indirect
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b // indirect
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 // indirect
)
require github.com/joho/godotenv v1.5.1

12
go.sum
View file

@ -1,14 +1,2 @@
github.com/bwmarrin/discordgo v0.29.0 h1:FmWeXFaKUwrcL3Cx65c20bTRW+vOb6k8AnaP+EgjDno=
github.com/bwmarrin/discordgo v0.29.0/go.mod h1:NJZpH+1AfhIcyQsPeuBKsUtYrRnjkyu0kIVMCHkZtRY=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b h1:7mWr3k41Qtv8XlltBkDkl8LoP3mpSgBW8BUoxtEdbXg=
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

View file

@ -42,7 +42,7 @@ func init() {
}
func main() {
go Untis.Run() //starting API calls function
go Untis.Auth() //starting API calls function
// Create a channel to receive OS signals
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)