test_20_in_mic.go 1.17 KB
Newer Older
hujiebin's avatar
hujiebin committed
1 2 3 4
package main

import (
	"fmt"
hujiebin's avatar
hujiebin committed
5 6 7
	"git.hilo.cn/hilo-common/model"
	"git.hilo.cn/hilo-common/mysql"
	"git.hilo.cn/hilo-common/utils/jwt"
hujiebin's avatar
hujiebin committed
8 9 10 11 12
	"net/http"
	"strings"
	"time"
)

hujiebin's avatar
hujiebin committed
13
var micCodes = []string{"1000653", "1000516", "1000675", "1000890", "1000755", "1000593", "1000629", "1000634", "1000765", "1000591", "1000633", "1000224", "1000611", "1000689", "1000467", "1000384", "1000367", "1000623"}
hujiebin's avatar
hujiebin committed
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46

func main() {
	var users []model.User
	if err := mysql.TestDB.Model(model.User{}).Where("code in ?", micCodes).Find(&users).Error; err != nil {
		panic(err)
	}
	for _, user := range users {
		url := "https://test.apiv1.faceline.live/v1/imGroup/mic/in"
		method := "POST"

		payload := strings.NewReader("groupUuid=HTGS%23a56194639&i=")

		client := &http.Client{}
		req, err := http.NewRequest(method, url, payload)

		if err != nil {
			fmt.Println(err)
			return
		}
		token, _ := jwt.GenerateToken(user.Id, user.ExternalId, "hiloApi")
		req.Header.Add("nonce", "hilo")
		req.Header.Add("token", token)
		req.Header.Add("Content-Type", "application/x-www-form-urlencoded")

		res, err := client.Do(req)
		if err != nil {
			fmt.Println(err)
			return
		}
		res.Body.Close()
		time.Sleep(time.Second * 2)
	}
}