コード例 #1
0
        /// <summary>
        /// 获取所有菜单
        /// </summary>
        /// <returns></returns>
        public string GetMenu()
        {
            //// 微信API地址
            string wxAPIURL = WebConfigeOpert.GetWXAPIURL();

            string strUrl = wxAPIURL + "cgi-bin/menu/get?access_token=" + WXTokenOpert.GetAccessToken();

            return(PublicTools.HttpGetRequestAsString(strUrl));
        }
コード例 #2
0
        /// <summary>
        /// 删除所有菜单
        /// </summary>
        /// <returns></returns>
        public MwxResult DeletMenu()
        {
            //// 微信API地址
            string wxAPIURL = WebConfigeOpert.GetWXAPIURL();

            string strUrl = wxAPIURL + "cgi-bin/menu/delete?access_token=" + WXTokenOpert.GetAccessToken();

            return(PublicTools.HttpGetRequest <MwxResult>(strUrl));
        }
コード例 #3
0
        /// <summary>
        /// 向微信服务器请求创建自定义菜单
        /// </summary>
        /// <param name="jsonStr"></param>
        /// <returns></returns>
        public MwxResult AddMenu(string jsonStr)
        {
            //// 处理结果对象
            MwxResult model = null;

            //// 微信API地址
            string interfaceUrl = WebConfigeOpert.GetWXAPIURL();

            interfaceUrl = string.IsNullOrEmpty(interfaceUrl) ? "https://api.weixin.qq.com/" : interfaceUrl;

            //声明一个HttpWebRequest请求
            interfaceUrl = string.Format("{0}cgi-bin/menu/create?access_token={1}", interfaceUrl, WXTokenOpert.GetAccessToken());

            model = PublicTools.HttpPostRequest <MwxResult>(interfaceUrl, jsonStr);

            return(model);
        }
コード例 #4
0
        /// <summary>
        /// 修改用户备注信息
        /// </summary>
        /// <param name="openid">被修改这者的openid</param>
        /// <param name="remark">修改后的备注信息</param>
        /// <returns></returns>
        public MwxResult CheckUserRemark(string openid, string remark)
        {
            //// 处理结果对象
            MwxResult model = null;

            //// 微信API地址
            string wxAPIURL = WebConfigeOpert.GetWXAPIURL();

            //声明一个HttpWebRequest请求
            string interfaceUrl = string.Format("{0}cgi-bin/user/info/updateremark?access_token={1}", wxAPIURL, WXTokenOpert.GetAccessToken());

            string jsonStr = "{" + "\"openid\";" + openid + ",\"remark\":" + remark + "}";

            model = PublicTools.HttpPostRequest <MwxResult>(interfaceUrl, jsonStr);

            return(model);
        }
コード例 #5
0
        /// <summary>
        /// 根据OpenID 获取用户基本信息(需关注公众号)
        /// </summary>
        /// <param name="openId"></param>
        public MWXUserInfo GetUserInfo(string openId)
        {
            //// 微信API地址
            string wxAPIURL = WebConfigeOpert.GetWXAPIURL();

            String      strUrl = string.Format("{0}cgi-bin/user/info?access_token={1}&openid={2}&lang=zh_CN", wxAPIURL, WXTokenOpert.GetAccessToken(), openId);
            MWXUserInfo model  = PublicTools.HttpGetRequest <MWXUserInfo>(strUrl);

            //// 对获取大的用户信息的关注日期和头像做处理
            if (model != null)
            {
                model.subscribe_time = PublicTools.GetDateTimeWithSecond(Convert.ToInt64(model.subscribe_time)).ToString("yyyy-MM-dd HH:mm:ss");
                model.headimgurl     = model.headimgurl.Substring(0, model.headimgurl.LastIndexOf('/') + 1);
            }

            return(model);
        }