Esempio n. 1
0
        public MsgSendResult SendTextMsg(string fakeid, string msg)
        {
            PreLogin();

            //refer是必须的,否则错误: need post
            var refer =
                string.Format(
                    "https://mp.weixin.qq.com/cgi-bin/singlemsgpage?fromfakeid={0}&count=20&t=wxm-singlechat&token={1}&lang=zh_CN",
                    fakeid, _token);
            var dic = new Dictionary <string, object>
            {
                { "type", TextMsg },
                { "content", msg },
                { "error", "false" },
                { "imgcode", "" },
                { "tofakeid", fakeid },
                { "token", _token },
                { "ajax", 1 },

                /*{"fid", 10000003},//后3个文本消息不需要
                 * {"fileid", 10000000},
                 * {"appmsgid", 10000003}*/
            };
            var r = HttpExtendedHelper.Post <MsgSendResult>(DefaultSendMsg, dic, _cc, refer)
                    ?? new MsgSendResult()
            {
                ret = -9999, msg = "未收到微信服务器响应"
            };

            return(r);
        }
Esempio n. 2
0
        public LoginRet Login()
        {
            //用于登录要发送的数据
            var dic = new Dictionary <string, object>
            {
                { "username", _userName },
                { "pwd", Md5(_pwd) },
                { "imgcode", string.Empty },
                { "f", "json" }
            };
            var ret = HttpExtendedHelper.Post <LoginRet>(DefaultLoginUrl, dic, _cc, DefaultLoginReferUrl)
                      ?? new LoginRet()
            {
                ErrCode = -9999, ErrMsg = "超时而未收到任何服务器响应"
            };

            if (ret.IsSuccess)
            {
                _token = Regex.Match(ret.ErrMsg, @"(?<=token=)\d+").Value;
            }
            else
            {
                ret.ErrMsg = MapErrCode(ret.ErrCode);
            }
            return(ret);
        }
Esempio n. 3
0
        public WxUserInfoFree ExecuteUserInfo(string fakeid)
        {
            PreLogin();

            var dic = new Dictionary <string, object>
            {
                { "token", _token },
                { "lang", Language },
                { "t", "ajax-getcontactinfo" },
                { "fakeid", fakeid }
            };
            //X-Requested-With:XMLHttpRequest
            var refer = "https://mp.weixin.qq.com/cgi-bin/contactmanage?";
            var p     = "t=user/index&pagesize=10&pageidx=0&type=0&groupid=100&token={0}&lang={1}";

            refer = string.Format(refer, _token, Language);
            return(HttpExtendedHelper.Post <WxUserInfoRespFree>(DefaultUserInfoUrl, dic, _cc, refer).contact_info);
        }