Пример #1
0
        /// <summary>
        /// 获取 用户信息
        /// </summary>
        /// <param name="entity">签名参数</param>
        /// <param name="code">临时授权码</param>
        /// <returns></returns>
        public static DingTalk_User_ResultEntity User(DingTalk_User_RequestEntity entity, string code)
        {
            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            string pars = LoginBase.EntityToPars(entity);

            var hwr = NetnrCore.HttpTo.HWRequest(DingTalkConfig.API_User + "?" + pars, "POST", NetnrCore.ToJson(new { tmp_auth_code = code }));

            hwr.ContentType = "application/json";
            var result = NetnrCore.HttpTo.Url(hwr);

            var ro = JObject.Parse(result);

            if (ro["errcode"].ToString() == "0")
            {
                result = NetnrCore.ToJson(JObject.Parse(result)["user_info"]);
            }
            else
            {
                return(null);
            }

            var outmo = LoginBase.ResultOutput <DingTalk_User_ResultEntity>(result);

            return(outmo);
        }
Пример #2
0
        /// <summary>
        /// Step3:获取个人信息
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static AliPay_User_ResultEntity User(AliPay_User_RequestEntity entity)
        {
            Signature(entity);

            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            string pars   = LoginBase.EntityToPars(entity);
            string result = Core.HttpTo.Get(AliPayConfig.API_Gateway + "?" + pars);

            AliPay_User_ResultEntity outmo = null;

            if (result.Contains("alipay_user_info_share_response"))
            {
                outmo = result.ToJObject()["alipay_user_info_share_response"].ToJson().ToEntity <AliPay_User_ResultEntity>();
            }

            if (result.Contains("error_response"))
            {
                outmo = result.ToJObject()["error_response"].ToJson().ToEntity <AliPay_User_ResultEntity>();
            }

            return(outmo);
        }
Пример #3
0
        /// <summary>
        /// Step2:获取授权过的Access Token
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static AliPay_AccessToken_ResultEntity AccessToken(AliPay_AccessToken_RequestEntity entity)
        {
            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            Signature(entity);

            string pars   = LoginBase.EntityToPars(entity);
            string result = Core.HttpTo.Get(AliPayConfig.API_Gateway + "?" + pars);

            AliPay_AccessToken_ResultEntity outmo = null;

            if (result.Contains("alipay_system_oauth_token_response"))
            {
                outmo = result.ToJObject()["alipay_system_oauth_token_response"].ToJson().ToEntity <AliPay_AccessToken_ResultEntity>();
            }

            if (result.Contains("error_response"))
            {
                outmo = result.ToJObject()["error_response"].ToJson().ToEntity <AliPay_AccessToken_ResultEntity>();
            }

            return(outmo);
        }
Пример #4
0
        /// <summary>
        /// Step3:获取个人信息
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static AliPay_User_ResultEntity User(AliPay_User_RequestEntity entity)
        {
            Signature(entity);

            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            string pars   = LoginBase.EntityToPars(entity);
            string result = NetnrCore.HttpTo.Get(AliPayConfig.API_Gateway + "?" + pars);

            string jkey = string.Empty;

            if (result.Contains("alipay_user_info_share_response"))
            {
                jkey = "alipay_user_info_share_response";
            }
            if (result.Contains("error_response"))
            {
                jkey = "error_response";
            }
            if (!string.IsNullOrEmpty(jkey))
            {
                var outmo = NetnrCore.ToEntity <AliPay_User_ResultEntity>(NetnrCore.ToJson(JObject.Parse(result)[jkey]));
                return(outmo);
            }

            return(null);
        }
Пример #5
0
        /// <summary>
        /// 获取access_token
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static DingTalk_AccessToken_ResultEntity AccessToken(DingTalk_AccessToken_RequestEntity entity)
        {
            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            string pars   = LoginBase.EntityToPars(entity);
            var    result = NetnrCore.HttpTo.Get(DingTalkConfig.API_AccessToken + "?" + pars);

            var outmo = LoginBase.ResultOutput <DingTalk_AccessToken_ResultEntity>(result);

            return(outmo);
        }
Пример #6
0
        /// <summary>
        /// Step2:获取授权过的Access Token
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static Weibo_AccessToken_ResultEntity AccessToken(Weibo_AccessToken_RequestEntity entity)
        {
            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            string pars   = LoginBase.EntityToPars(entity);
            string result = LoginBase.RequestTo.Url(WeiboConfig.API_AccessToken, pars);

            var outmo = LoginBase.ResultOutput <Weibo_AccessToken_ResultEntity>(result);

            return(outmo);
        }
Пример #7
0
        /// <summary>
        /// Step3:查询用户access_token的授权相关信息,包括授权时间,过期时间和scope权限。
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static Weibo_GetTokenInfo_ResultEntity GetTokenInfo(Weibo_GetTokenInfo_RequestEntity entity)
        {
            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            string pars   = LoginBase.EntityToPars(entity);
            string result = Core.HttpTo.Post(WeiboConfig.API_GetTokenInfo, pars);

            var outmo = LoginBase.ResultOutput <Weibo_GetTokenInfo_ResultEntity>(result);

            return(outmo);
        }
Пример #8
0
        /// <summary>
        /// Step4:获取用户信息
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static QQ_OpenId_get_user_info_ResultEntity OpenId_Get_User_Info(QQ_OpenAPI_RequestEntity entity)
        {
            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            string pars   = LoginBase.EntityToPars(entity);
            string result = NetnrCore.HttpTo.Get(QQConfig.API_Get_User_Info + "?" + pars);

            var outmo = LoginBase.ResultOutput <QQ_OpenId_get_user_info_ResultEntity>(result.Replace("\r\n", ""));

            return(outmo);
        }
Пример #9
0
        /// <summary>
        /// 获取 access token
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static MicroSoft_AccessToken_ResultEntity AccessToken(MicroSoft_AccessToken_RequestEntity entity)
        {
            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            string pars = LoginBase.EntityToPars(entity);

            string result = NetnrCore.HttpTo.Post(MicroSoftConfig.API_AccessToken, pars);

            var outmo = LoginBase.ResultOutput <MicroSoft_AccessToken_ResultEntity>(result);

            return(outmo);
        }
Пример #10
0
        /// <summary>
        /// 获取 用户信息
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static Gitee_User_ResultEntity User(Gitee_User_RequestEntity entity)
        {
            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            string pars = LoginBase.EntityToPars(entity);

            var result = Core.HttpTo.Get(GiteeConfig.API_User + "?" + pars);

            var outmo = LoginBase.ResultOutput <Gitee_User_ResultEntity>(result);

            return(outmo);
        }
Пример #11
0
        /// <summary>
        /// 获取 access token
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static Gitee_AccessToken_ResultEntity AccessToken(Gitee_AccessToken_RequestEntity entity)
        {
            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            string pars = LoginBase.EntityToPars(entity);

            var result = Core.HttpTo.Post(GiteeConfig.API_AccessToken, pars);

            var outmo = LoginBase.ResultOutput <Gitee_AccessToken_ResultEntity>(result);

            return(outmo);
        }
Пример #12
0
        /// <summary>
        /// 获取access_token
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static StackOverflow_AccessToken_ResultEntity AccessToken(StackOverflow_AccessToken_RequestEntity entity)
        {
            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            string pars   = LoginBase.EntityToPars(entity);
            var    result = NetnrCore.HttpTo.Post(StackOverflowConfig.API_AccessToken, pars);

            result = "{\"" + result.Replace("=", "\":\"").Replace("&", "\",\"") + "\"}";

            var outmo = LoginBase.ResultOutput <StackOverflow_AccessToken_ResultEntity>(result);

            return(outmo);
        }
Пример #13
0
        /// <summary>
        /// Step4:根据用户ID获取用户信息
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static Weibo_UserShow_ResultEntity UserShow(Weibo_UserShow_RequestEntity entity)
        {
            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            string pars   = LoginBase.EntityToPars(entity);
            string result = Core.HttpTo.Get(WeiboConfig.API_UserShow + "?" + pars);

            var outmo = LoginBase.ResultOutput <Weibo_UserShow_ResultEntity>(result, new List <string> {
                "status"
            });

            return(outmo);
        }
Пример #14
0
        /// <summary>
        /// 获取 access token
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static Gitee_AccessToken_ResultEntity AccessToken(Gitee_AccessToken_RequestEntity entity)
        {
            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            string pars = LoginBase.EntityToPars(entity);

            var hwr = LoginBase.HttpTo.HWRequest(GiteeConfig.API_AccessToken, "POST", pars);

            hwr.Accept = "application/json";//application/xml
            string result = LoginBase.HttpTo.Url(hwr);

            var outmo = LoginBase.ResultOutput <Gitee_AccessToken_ResultEntity>(result);

            return(outmo);
        }
Пример #15
0
        /// <summary>
        /// 获取 用户信息
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static MicroSoft_User_ResultEntity User(MicroSoft_User_RequestEntity entity)
        {
            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            string pars = LoginBase.EntityToPars(entity);

            var hwr = Core.HttpTo.HWRequest(MicroSoftConfig.API_User + "?" + pars);

            hwr.ContentType = null;
            string result = Core.HttpTo.Url(hwr);
            var    outmo  = LoginBase.ResultOutput <MicroSoft_User_ResultEntity>(result, new List <string> {
                "emails"
            });

            return(outmo);
        }
Пример #16
0
        /// <summary>
        /// 获取 用户信息
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static Gitee_User_ResultEntity User(Gitee_User_RequestEntity entity)
        {
            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            string pars = LoginBase.EntityToPars(entity);

            var hwr = LoginBase.HttpTo.HWRequest(GiteeConfig.API_User + "?" + pars);

            hwr.UserAgent = entity.ApplicationName;
            string result = LoginBase.HttpTo.Url(hwr);

            var outmo = LoginBase.ResultOutput <Gitee_User_ResultEntity>(result, new List <string> {
                "plan"
            });

            return(outmo);
        }
Пример #17
0
        /// <summary>
        /// Step3:获取用户OpenId
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static QQ_OpenId_ResultEntity OpenId(QQ_OpenId_RequestEntity entity)
        {
            var mo  = new QQ_OpenId_ResultEntity();
            var pis = mo.GetType().GetProperties();

            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            string pars   = LoginBase.EntityToPars(entity);
            string result = LoginBase.RequestTo.Url(QQConfig.API_OpenID_PC + "?" + pars);

            //callback( {"client_id":"xx12196xx","openid":"09196B48CA96A8C8ED4FFxxCBxx59Dxx"} );
            result = result.Replace("callback( ", "").Replace(" );", "");

            var outmo = LoginBase.ResultOutput <QQ_OpenId_ResultEntity>(result);

            return(outmo);
        }
Пример #18
0
        /// <summary>
        /// 获取 用户信息
        /// </summary>
        /// <param name="entity">签名参数</param>
        /// <returns></returns>
        public static StackOverflow_User_ResultEntity User(StackOverflow_User_RequestEntity entity)
        {
            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            string pars   = LoginBase.EntityToPars(entity);
            string result = NetnrCore.HttpTo.Get(StackOverflowConfig.API_User + "?" + pars);

            StackOverflow_User_ResultEntity outmo = null;

            var jo = JObject.Parse(result);

            if (jo.ContainsKey("items"))
            {
                outmo = LoginBase.ResultOutput <StackOverflow_User_ResultEntity>(NetnrCore.ToJson(jo["items"][0]));
            }

            return(outmo);
        }
Пример #19
0
        /// <summary>
        /// Step2:通过Authorization Code获取Access Token
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static QQ_AccessToken_ResultEntity AccessToken(QQ_AccessToken_RequestEntity entity)
        {
            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            string pars = LoginBase.EntityToPars(entity);

            string result = NetnrCore.HttpTo.Get(QQConfig.API_AccessToken_PC + "?" + pars);

            List <string> listPars = result.Split('&').ToList();
            var           jo       = new JObject();

            foreach (string item in listPars)
            {
                var items = item.Split('=').ToList();
                jo[items.FirstOrDefault()] = items.LastOrDefault();
            }

            var outmo = LoginBase.ResultOutput <QQ_AccessToken_ResultEntity>(Newtonsoft.Json.JsonConvert.SerializeObject(jo));

            return(outmo);
        }