Esempio n. 1
0
        /// <summary>
        /// 获取二维码Ticket
        /// </summary>
        /// <param name="scene_id">场景标识</param>
        /// <returns>接口返回值</returns>
        public wx_backdata <wx_oauth2token> GetOauth2AccessToken(string code)
        {
            string Url       = "https://api.weixin.qq.com/sns/oauth2/access_token?";
            string GetResult = ToolKit.GetData(Url + "appid=" + appid + "&secret=" + secret + "&code=" + code + "&grant_type=authorization_code");

            return(GetJson <wx_oauth2token>(GetResult));
        }
Esempio n. 2
0
        /// <summary>
        /// 获取指定用户信息
        /// </summary>
        /// <param name="openid">用户标识</param>
        /// <returns>接口返回值</returns>
        public wx_backdata <wx_user_info> GetUserInfo(string openid)
        {
            string Url       = "https://api.weixin.qq.com/cgi-bin/user/info?";
            string GetResult = ToolKit.GetData(Url + "access_token=" + this.Accesstoken() + "&openid=" + openid + "&lang=zh_CN");

            return(GetJson <wx_user_info>(GetResult));
        }
Esempio n. 3
0
        /// <summary>
        /// 获取粉丝微信OpenId
        /// </summary>
        /// <returns>接口返回值</returns>
        public wx_backdata <wx_openidlist> GetOpenIdList()
        {
            string Url       = "https://api.weixin.qq.com/cgi-bin/user/get?";
            string GetResult = ToolKit.GetData(Url + "access_token=" + this.Accesstoken() + "&next_openid=");

            return(GetJson <wx_openidlist>(GetResult));
        }
Esempio n. 4
0
        /// <summary>
        /// 根据接口返回代码42001验证是否可用
        /// </summary>
        /// <returns>true可用|false失效</returns>
        public bool check_access_token()
        {
            XmlDocument Xml = new XmlDocument();

            Xml.Load(HttpContext.Current.Server.MapPath(WEIXIN_CONFIG_PATH));
            XmlNode access_token = Xml.SelectSingleNode("weixin/accesstoken");

            if (access_token != null)
            {
                this.accesstoken = access_token.InnerText;
            }
            string Url       = "https://api.weixin.qq.com/cgi-bin/get_current_selfmenu_info?access_token=" + this.accesstoken;
            string GetResult = ToolKit.GetData(Url);

            if (GetResult.IndexOf("errcode") != -1)
            {
                var ErrorMessage = JsonConvert.DeserializeObject <wx_apperror>(GetResult);
                if (ErrorMessage.errcode == "42001")
                {
                    return(false);
                }
                return(false);
            }
            else
            {
                return(true);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 获取唯一接口调用凭据access_token
        /// </summary>
        /// <returns>access_token获取结果对象</returns>
        public wx_backdata <wx_access_token> get_access_token()
        {
            string Url        = "https://api.weixin.qq.com/cgi-bin/token?";
            string grant_type = "client_credential";
            string GetResult  = ToolKit.GetData(Url + "grant_type=" + grant_type + "&appid=" + appid + "&secret=" + secret);

            return(GetJson <wx_access_token>(GetResult));
        }