Ejemplo n.º 1
0
///	获取用户列表并报错到redis数据库中 KEY=wx_UserList
func GetUserList() {
	url := "https://api.weixin.qq.com/cgi-bin/user/get?access_token=" + GetAccessToken()
	key := "wx_UserList"
	var v WXUserList
	c, status := global.HttpGet(url)
	if status >= 0 {
		dec := json.NewDecoder(strings.NewReader(c))
		for {
			if err := dec.Decode(&v); err == io.EOF {
				break
			} else if err != nil {
				log.Fatal(err)
			}
		}

		var redcli redis.Client
		redcli.Addr = beego.AppConfig.String("redis_addr")

		if ok, err := redcli.Exists(key); err != nil {
			log.Println(err.Error())
		} else {
			if ok {
				redcli.Del(key)
			}
		}
		for _, value := range v.Data.Openid {
			redcli.Rpush(key, []byte(value))
		}
		log.Println("Successful: Add Userlist ")
	}
}
Ejemplo n.º 2
0
func ReceiveScanEvent(content string) string {
	var this ScanEvent
	fmt.Println(content)
	err := xml.Unmarshal([]byte(content), &this)
	if err != nil {
		return ""
	}
	data := "请联系系统管理员进行身份认证"
	if "101" == this.EventKey &&
		"oecJ3jhN5usPBQMIXqc9bVP0toi4" == this.Ticket {
		data = "吼吼吼"
		var redcli redis.Client
		redcli.Addr = beego.AppConfig.String("redis_addr")
		redcli.Hset(this.Ticket, "scan", []byte("true"))
	}
	fmt.Println(data)
	rcontent := `<xml>
<ToUserName><![CDATA[` + this.FromUserName + `]]></ToUserName>
<FromUserName><![CDATA[` + this.ToUserName + `]]></FromUserName>
<CreateTime>` + fmt.Sprint((time.Now().Unix())) + `</CreateTime>
<MsgType><![CDATA[text]]></MsgType>
<Content><![CDATA[` + data + `]]></Content>
</xml>`
	return rcontent
}
Ejemplo n.º 3
0
/// 获取用户信息列表
func GetUserListInfo() {
	var redcli redis.Client
	redcli.Addr = beego.AppConfig.String("redis_addr")
	key := "wx_UserList"
	b, _ := redcli.Lrange(key, 0, -1)
	for _, v := range b {
		GetUserInfo(fmt.Sprintf("%s", v))
	}
}
Ejemplo n.º 4
0
func GetTempTicket(expire_seconds int, scene_id int, scene_str string) string {
	url := `https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=` + GetAccessToken()
	data := `{"expire_seconds": ` + strconv.Itoa(expire_seconds) +
		`, "action_name": "QR_SCENE", ` +
		`"action_info": {"scene": {"scene_id": ` + strconv.Itoa(scene_id) +
		`,"scene_str":"` + scene_str + `"}}}`
	if ticket := getTicket(url, data); len(ticket) < 1 {
		return ""
	} else {
		var redcli redis.Client
		redcli.Addr = beego.AppConfig.String("redis_addr")
		redcli.Hset(ticket, "scene_id", []byte(strconv.Itoa(scene_id)))
		redcli.Expire(ticket, 120)
		return ticket
	}
}