Exemplo n.º 1
0
        /// <summary>
        /// 同步公众号所用粉丝
        /// </summary>
        /// <param name="wxAccount"></param>
        public void SyncAllWXUser(WeChatAccount wxAccount, string next_openid)
        {
            if (wxAccount.type == WeChatAccountType.AuthSubscriber || wxAccount.type == WeChatAccountType.AuthService)
            {
                //获取ToKen
                WXAccessTokenCache token     = ServiceIoc.Get <WeChatTokenService>().AccessToken(wxAccount.appid, wxAccount.app_secret);
                string             user_list = WeChatUserHelper.GetWXUserList(token.token, next_openid);
                WeChatUserBase     wxUsers   = JsonConvert.DeserializeObject <WeChatUserBase>(user_list);

                if (wxUsers.data != null)
                {
                    //open_id 集合
                    string[] open_ids = wxUsers.data.openid;

                    //遍历
                    foreach (string open_id in open_ids)
                    {
                        //通过微信接口获取
                        string WeChatUser_json = WeChatUserHelper.GetWXUserInfo(token.token, open_id);

                        //序列化用户
                        WeChatUser WeChatUser = JsonConvert.DeserializeObject <WeChatUser>(WeChatUser_json);

                        SyncWXUser(WeChatUser);
                    }

                    //存在下一openid
                    if (!string.IsNullOrEmpty(wxUsers.next_openid))
                    {
                        SyncAllWXUser(wxAccount, wxUsers.next_openid);
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 扫描二维码关注 同步粉丝信息
        /// </summary>
        /// <param name="open_id"></param>
        /// <param name="phone"></param>
        public void Subscribe(WeChatAccountTmp account, string open_id, long user_id)
        {
            //获取ToKen
            WXAccessTokenCache token = ServiceIoc.Get <WeChatTokenService>().AccessToken(account.appid, account.app_secret);

            //通过微信接口获取
            string WeChatUser_json = WeChatUserHelper.GetWXUserInfo(token.token, open_id);
            //序列化用户
            WeChatUser user = JsonConvert.DeserializeObject <WeChatUser>(WeChatUser_json);

            SyncWXUser(user, user_id);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 同步单一粉丝
        /// 关注时同步
        /// </summary>
        /// <param name="open_id"></param>
        /// <param name="wxAccount"></param>
        public void SyncSingleWXUser(string open_id, WeChatAccount wxAccount)
        {
            //获取ToKen
            WXAccessTokenCache token = ServiceIoc.Get <WeChatTokenService>().AccessToken(wxAccount.appid, wxAccount.app_secret);

            //通过微信接口获取
            string WeChatUser_json = WeChatUserHelper.GetWXUserInfo(token.token, open_id);

            //序列化用户
            WeChatUser WeChatUser = JsonConvert.DeserializeObject <WeChatUser>(WeChatUser_json);

            SyncWXUser(WeChatUser);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 同步微信用户分组
        /// </summary>
        /// <param name="wxaccount"></param>
        /// <param name="open_id"></param>
        /// <param name="tableConfig"></param>
        public void SyncWXGroup(WeChatAccount wxAccount, string open_id)
        {
            //获取token
            WXAccessTokenCache token = ServiceIoc.Get <WeChatTokenService>().AccessToken(wxAccount.appid, wxAccount.app_secret);

            //公众号粉丝集合
            string groups = WeChatUserHelper.GetWxGroups(token.token);

            //序列化数据
            string[] groupslist = JsonConvert.DeserializeObject <string[]>(groups);

            foreach (string s in groupslist)
            {
            }
            //open_ids
        }