commit e19ddd046cf7cf8f197104a5170caa829f9765e1 Author: Geno Date: Thu Nov 19 17:15:54 2020 +0100 get join url from a greenlight diff --git a/main.go b/main.go new file mode 100644 index 0000000..2de8191 --- /dev/null +++ b/main.go @@ -0,0 +1,54 @@ +package main + +import ( + "fmt" + "log" + "net/http" + "net/url" + "os" + + "github.com/PuerkitoBio/goquery" +) + +func main() { + bbbName := "bbbBot" + bbbURL, _ := url.Parse(os.Args[1]) + + res, err := http.Get(bbbURL.String()) + if err != nil { + log.Fatal(err) + } + defer res.Body.Close() + if res.StatusCode != 200 { + log.Fatalf("status code error: %d %s", res.StatusCode, res.Status) + } + + doc, err := goquery.NewDocumentFromReader(res.Body) + if err != nil { + log.Fatal(err) + } + form := doc.Find("form") + authToken, ok := form.Find("input[name='authenticity_token']").Attr("value") + if !ok { + log.Fatalln("'authenticity_token' not found") + } + res.Body.Close() + // ---- + res, err = http.PostForm(bbbURL.String(), url.Values{ + "authenticity_token": {authToken}, + fmt.Sprintf("%s[join_name]", bbbURL.Path): {bbbName}, + }) + //defer res.Body.Close() + if res.StatusCode != 200 { + log.Fatalf("status code error: %d %s", res.StatusCode, res.Status) + } + log.Printf("%v", res.Request.Header.Get("Referer")) + + /* not needed ... websocket + doc, err = goquery.NewDocumentFromReader(res.Body) + if err != nil { + log.Fatal(err) + } + log.Println(doc.Html()) + */ +}