Exemplo n.º 1
0
func main() {
	cre, err := wxgo.GetCredential("", "")
	if nil != err {
		log.Println(err)
		return
	}
	for i := 0; i < 1; i++ {
		go func(i int) {
			userInfo, userErr := wxuser.GetUserInfo(cre, "o7jf2s3-qYJXKdCwnKBPO4tfNKDg")
			if nil != userErr {
				log.Println(err)
				return
			}
			fmt.Println(i, " - ", userInfo)
		}(i)
	}
	select {}
}
Exemplo n.º 2
0
func main() {
	cre, err := wxgo.GetCredential("", "")
	if nil != err {
		log.Println(err)
		return
	}
	for i := 0; i < 1; i++ {
		go func() {
			fmt.Println("1")
			list, err := wxuser.GetUserList(cre, "")
			fmt.Println("2")
			if nil != err {
				log.Println(err)
				return
			}
			fmt.Println(list)
		}()
	}
	select {}

}
Exemplo n.º 3
0
func main() {
	cre, err := wxgo.GetCredential("", "")
	if nil != err {
		log.Println(err)
		return
	}
	var data interface{}

	str := "[:0x1F604:]Hello World [:0x1F44A:] [:0x2728:]"

	re, _ := regexp.Compile("[:0x[0-9a-zA-Z]{3,11}:]")
	newStr := string(re.ReplaceAllFunc([]byte(str), func(b []byte) []byte {
		str := string(b)
		code := strings.Replace(str, "[:", "", -1)
		code = strings.Replace(code, ":]", "", -1)
		s, e := strconv.ParseInt(code, 0, 0)
		if nil != e {
			return b
		}
		return []byte(string(rune(s)))
	}))

	json.Unmarshal([]byte(`{"first": {"value":"`+newStr+`"},"keyword1":{"value":"巧克力"},"keyword2": {"value":"39.8元"},"remark":{"value":"欢迎再次购买!"}}`), &data)
	req := request.SendTemplateReq{
		ToUser:     "******",
		TemplateID: "qj5CxfeAb_B3PBDtT0Gu93608UiDxVWNxqtAhU8pZvE",
		URL:        "",
		Data:       data,
	}

	log.Println(req)

	res, msgErr := message.SendTemplate(cre, req)
	if nil != msgErr {
		log.Println(msgErr)
	}
	fmt.Print(res)
}