Esempio n. 1
0
        /// <summary>
        /// 创建二维码ticket
        /// </summary>
        /// <param name="user"></param>
        /// <param name="codetype">0永久1临时二维码</param>
        /// <returns></returns>
        public string QrCode(int codetype, Lebi_User user = null)
        {
            string result = "";
            //QR_SCENE临时二维码   QR_LIMIT_SCENE永久二维码
            string codetypestr = "QR_LIMIT_SCENE";

            if (codetype == 1)
            {
                codetypestr = "QR_SCENE";
            }
            if (user == null)
            {
                user = new Lebi_User();
            }
            string strJson = "{\"action_name\": \"" + codetypestr + "\", \"action_info\": {\"scene\": {\"scene_id\":" + user.id + "}}}";
            string res     = Post("https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" + Token + "", strJson);

            //content:{"errcode":40001,"errmsg":"invalid credential, access_token is invalid or not latest hint: [vbHGEa0238vr32!]"}
            if (res.Contains("invalid credential"))
            {
                _Instance = new weixin();
                //return QrCode(codetype, user);
                return("error");
            }
            JavaScriptSerializer jss = new JavaScriptSerializer();

            Model.weixin.Ticket ticket = jss.Deserialize <Model.weixin.Ticket>(res);

            LB.Tools.TxtLog.Add(res);
            result = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + ticket.ticket;
            return(result);
        }
Esempio n. 2
0
        public static weixin GetInstance(int _DT_id, Lebi_Site CurrentSite = null)
        {
            weixin wx = new weixin(_DT_id, CurrentSite);

            return(wx);
        }