genofire
/
bbb-fetcher
Archived
1
0
Fork 0

get join url from a greenlight

This commit is contained in:
Geno 2020-11-19 17:15:54 +01:00
commit e19ddd046c
1 changed files with 54 additions and 0 deletions

54
main.go Normal file
View File

@ -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())
*/
}