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

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

hujiebin's avatar
hujiebin committed
13 14
//var micCodes = []string{"1000653", "1000516", "1000675", "1000890", "1000755", "1000593", "1000629", "1000634", "1000765", "1000591", "1000633", "1000224", "1000611", "1000689", "1000467", "1000384", "1000367", "1000623"}
var micCodes = []string{"1110189", "1110188", "1110186", "1110183", "1110180", "1110175", "1110170", "1110160", "1110158", "1110154", "1110152", "1110150", "1110141", "1110139", "1110130", "199777", "1110124", "1110122", "1110120", "1110118"}
hujiebin's avatar
hujiebin committed
15 16 17 18 19 20 21 22 23 24

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"

hujiebin's avatar
hujiebin committed
25
		payload := strings.NewReader("groupUuid=HTGS%23a50923362&i=")
hujiebin's avatar
hujiebin committed
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47

		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)
	}
}