Example #1
0
        /// <summary>
        /// (基础方法)获得所有关注用户的openid字符串
        /// 递归算法
        /// </summary>
        /// <param name="nexOpenid"></param>
        /// <param name="openidList"></param>
        private void getNextUserOpenid(int wid, string nexOpenid, IList <string> openidList)
        {
            string           err          = "";
            string           access_token = WeiXinCRMComm.getAccessToken(wid, out err);
            OpenIdResultJson openidJson   = UserApi.Get(access_token, nexOpenid);

            if (openidJson == null || openidJson.count <= 0)
            {
                //return openidJson.data.openid;
                return;
            }
            else
            {
                for (int i = 0; i < openidJson.data.openid.Count; i++)
                {
                    openidList.Add(openidJson.data.openid[i]);
                }
                getNextUserOpenid(wid, openidJson.next_openid, openidList);
            }
        }
Example #2
0
        /// <summary>
        /// 获得所有关注用户的openid字符串(别的方法调用此方法)
        /// </summary>
        /// <returns></returns>
        private IList <string> baseUserOpenid(int wid, out string error)
        {
            IList <string> ret = new List <string>();

            string access_token = WeiXinCRMComm.getAccessToken(wid, out error);

            if (error != "")
            {
                return(null);
            }
            OpenIdResultJson openidJson = UserApi.Get(access_token, "");

            if (openidJson.count == openidJson.total)
            {
                ret = openidJson.data.openid;
            }
            else
            {
                getNextUserOpenid(wid, openidJson.next_openid, ret);
            }

            return(ret);
        }