Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 实体 转 Pars
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static string EntityToPars <T>(T entity)
        {
            string result = string.Empty;
            var    pis    = entity.GetType().GetProperties();

            foreach (var pi in pis)
            {
                string value = pi.GetValue(entity, null)?.ToString();
                if (value != null)
                {
                    result += "&" + pi.Name + "=" + NetnrCore.ToEncode(value);
                }
            }
            return(result.TrimStart('&'));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Step1:获取Authorization Code
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static string AuthorizationHref(QQ_Authorization_RequestEntity entity)
        {
            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            return(string.Concat(new string[] {
                QQConfig.API_Authorization_PC,
                "?client_id=",
                entity.client_id,
                "&response_type=",
                entity.response_type,
                "&state=",
                entity.state,
                "&redirect_uri=",
                NetnrCore.ToEncode(entity.redirect_uri)
            }));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 请求授权地址
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static string AuthorizeHref(StackOverflow_Authorize_RequestEntity entity)
        {
            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            return(string.Concat(new string[] {
                StackOverflowConfig.API_Authorize,
                "?client_id=",
                entity.client_id,
                "&scope=",
                entity.scope,
                "&state=",
                entity.state,
                "&redirect_uri=",
                NetnrCore.ToEncode(entity.redirect_uri)
            }));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 请求授权地址
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static string AuthorizeHref(MicroSoft_Authorize_RequestEntity entity)
        {
            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            return(string.Concat(new string[] {
                MicroSoftConfig.API_Authorize,
                "?client_id=",
                entity.client_id,
                "&scope=",
                entity.scope,
                "&response_type=",
                entity.response_type,
                "&redirect_uri=",
                NetnrCore.ToEncode(entity.redirect_uri)
            }));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Step1:请求用户授权Token
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static string AuthorizeHref(AliPay_Authorize_RequestEntity entity)
        {
            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            return(string.Concat(new string[] {
                AliPayConfig.API_Authorize,
                "?app_id=",
                entity.app_id,
                "&state=",
                entity.state,
                "&redirect_uri=",
                NetnrCore.ToEncode(entity.redirect_uri),
                "&scope=",
                entity.scope
            }));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 请求授权地址,密码登录
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static string AuthorizeHref_Password(DingTalk_Authorize_RequestEntity entity)
        {
            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            return(string.Concat(new string[] {
                DingTalkConfig.API_Authorize_Password,
                "?appid=",
                entity.appid,
                "&response_type=",
                entity.response_type,
                "&scope=",
                entity.scope,
                "&state=",
                entity.state,
                "&redirect_uri=",
                NetnrCore.ToEncode(entity.redirect_uri)
            }));
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Step3:获取用户OpenId
        /// </summary>
        /// <param name="access_token"></param>
        /// <returns></returns>
        public static QQ_OpenId_ResultEntity OpenId(string access_token)
        {
            if (string.IsNullOrWhiteSpace(access_token))
            {
                return(null);
            }

            string result = NetnrCore.HttpTo.Get($"{QQConfig.API_OpenID_PC}?access_token={NetnrCore.ToEncode(access_token)}");

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

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

            return(outmo);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 获取 用户信息
        /// </summary>
        /// <param name="access_token"></param>
        /// <returns></returns>
        public static MicroSoft_User_ResultEntity User(string access_token)
        {
            if (string.IsNullOrWhiteSpace(access_token))
            {
                return(null);
            }

            var hwr = NetnrCore.HttpTo.HWRequest($"{MicroSoftConfig.API_User}?access_token={NetnrCore.ToEncode(access_token)}");

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

            return(outmo);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Step3:查询用户access_token的授权相关信息,包括授权时间,过期时间和scope权限。
        /// </summary>
        /// <param name="access_token"></param>
        /// <returns></returns>
        public static Weibo_GetTokenInfo_ResultEntity GetTokenInfo(string access_token)
        {
            if (string.IsNullOrWhiteSpace(access_token))
            {
                return(null);
            }

            string result = NetnrCore.HttpTo.Post(WeiboConfig.API_GetTokenInfo, $"access_token={NetnrCore.ToEncode(access_token)}");

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

            return(outmo);
        }