Exemple #1
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <returns></returns>
        public bool init()
        {
            string  ReturnValue = Http.WebPost(base_uri + "/webwxinit?r=" + Common.ConvertDateTimeToInt(DateTime.Now) + "&lang=en_US" + "&pass_ticket=" + pass_ticket, base_request);
            JObject init_result = JsonConvert.DeserializeObject(ReturnValue) as JObject;

            _me                 = new wxUser();
            _me.UserName        = init_result["User"]["UserName"].ToString();
            _me.City            = "";
            _me.HeadImgUrl      = init_result["User"]["HeadImgUrl"].ToString();
            _me.NickName        = init_result["User"]["NickName"].ToString();
            _me.Province        = "";
            _me.PYQuanPin       = init_result["User"]["PYQuanPin"].ToString();
            _me.RemarkName      = init_result["User"]["RemarkName"].ToString();
            _me.RemarkPYQuanPin = init_result["User"]["RemarkPYQuanPin"].ToString();
            _me.Sex             = init_result["User"]["Sex"].ToString();
            _me.Signature       = init_result["User"]["Signature"].ToString();
            foreach (JObject synckey in init_result["SyncKey"]["List"])  //同步键值
            {
                dic_sync_key.Add(synckey["Key"].ToString(), synckey["Val"].ToString());
            }
            foreach (KeyValuePair <string, string> p in dic_sync_key)
            {
                sync_key_str += p.Key + "_" + p.Value + "%7C";
            }
            sync_key_str = sync_key_str.TrimEnd('%', '7', 'C');
            return(init_result["BaseResponse"]["Ret"].ToString() == "0");
        }
Exemple #2
0
        /// <summary>
        /// 获取当前账户的所有相关账号(包括联系人、公众号、群聊、特殊账号)
        /// </summary>
        public void get_contact()
        {
            contact_list.Clear();
            public_list.Clear();
            special_list.Clear();
            group_list.Clear();
            encry_chat_room_id_list.Clear();

            string[] special_users = { "newsapp",          "fmessage",              "filehelper",           "weibo",     "qqmail",
                                       "fmessage",         "tmessage",              "qmessage",             "qqsync",    "floatbottle",
                                       "lbsapp",           "shakeapp",              "medianote",            "qqfriend",  "readerapp",
                                       "blogapp",          "facebookapp",           "masssendapp",          "meishiapp",
                                       "feedsapp",         "voip",                  "blogappweixin",        "weixin",    "brandsessionholder",
                                       "weixinreminder",   "wxid_novlwrv3lqwv11",   "gh_22b87fa7cb3c",
                                       "officialaccounts", "notification_messages", "wxid_novlwrv3lqwv11",
                                       "gh_22b87fa7cb3c",  "wxitil",                "userexperience_alarm", "notification_messages" };

            string  contact_str    = Http.WebGet(base_uri + "/webwxgetcontact?pass_ticket=" + pass_ticket + "&skey=" + skey + "&r=" + Common.ConvertDateTimeToInt(DateTime.Now));
            JObject contact_result = JsonConvert.DeserializeObject(contact_str) as JObject;

            if (contact_result != null)
            {
                foreach (JObject contact in contact_result["MemberList"]) //完整好友名单
                {
                    wxUser user = new wxUser();
                    user.UserName        = contact["UserName"].ToString();
                    user.City            = contact["City"].ToString();
                    user.HeadImgUrl      = contact["HeadImgUrl"].ToString();
                    user.NickName        = contact["NickName"].ToString();
                    user.Province        = contact["Province"].ToString();
                    user.PYQuanPin       = contact["PYQuanPin"].ToString();
                    user.RemarkName      = contact["RemarkName"].ToString();
                    user.RemarkPYQuanPin = contact["RemarkPYQuanPin"].ToString();
                    user.Sex             = contact["Sex"].ToString();
                    user.Signature       = contact["Signature"].ToString();

                    if ((int.Parse(contact["VerifyFlag"].ToString()) & 8) != 0) //公众号
                    {
                        public_list.Add(user);
                    }
                    else if (special_users.Contains(contact["UserName"].ToString())) //特殊账户
                    {
                        special_list.Add(user);
                    }
                    else if (contact["UserName"].ToString().IndexOf("@@") != -1) //群聊
                    {
                        group_list.Add(user);
                    }
                    else
                    {
                        contact_list.Add(user); //联系人
                    }
                }
            }
            //foreach( )
        }
Exemple #3
0
 public string get_user_id(List <object> contact_list, string Name)
 {
     foreach (Object u in contact_list)
     {
         wxUser user = u as wxUser;
         if (user != null)
         {
             if (user.RemarkName == Name || user.NickName == Name)  //接收别人消息
             {
                 return(user.UserName);
             }
         }
         else
         {
             return("");
         }
     }
     return("");
 }
Exemple #4
0
 /// <summary>
 /// 判断用户是否是特殊号
 /// </summary>
 /// <param name="Name"></param>
 /// <returns></returns>
 public bool is_special(string Name)
 {
     foreach (Object u in special_list)
     {
         wxUser user = u as wxUser;
         if (user != null)
         {
             if (user.UserName == Name)
             {
                 return(true);
             }
         }
         else
         {
             return(false);
         }
     }
     return(false);
 }