Esempio n. 1
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);
        }
Esempio n. 2
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);
        }
Esempio n. 3
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);
        }
Esempio n. 4
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);
        }
Esempio n. 5
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);
        }
Esempio n. 6
0
        /// <summary>
        /// 请求授权地址
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static string AuthorizeHref(Gitee_Authorize_RequestEntity entity)
        {
            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            return(string.Concat(new string[] {
                GiteeConfig.API_Authorize,
                "?client_id=",
                entity.client_id,
                "&response_type=",
                entity.response_type,
                "&redirect_uri=",
                LoginBase.EncodeUri(entity.redirect_uri)
            }));
        }
Esempio n. 7
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);
        }
Esempio n. 8
0
        /// <summary>
        /// Step1:请求用户授权Token
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static string AuthorizeHref(Weibo_Authorize_RequestEntity entity)
        {
            if (!LoginBase.IsValid(entity))
            {
                return(null);
            }

            return(string.Concat(new string[] {
                WeiboConfig.API_Authorize,
                "?client_id=",
                entity.client_id,
                "&response_type=",
                entity.response_type,
                "&state=",
                entity.state,
                "&redirect_uri=",
                entity.redirect_uri.ToEncode()
            }));
        }
Esempio n. 9
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)
            }));
        }
Esempio n. 10
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)
            }));
        }
Esempio n. 11
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)
            }));
        }
Esempio n. 12
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);
        }
Esempio n. 13
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=",
                entity.redirect_uri.ToEncode(),
                "&scope=",
                entity.scope
            }));
        }
Esempio n. 14
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);
        }
Esempio n. 15
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);
        }
Esempio n. 16
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)
            }));
        }
Esempio n. 17
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);
        }
Esempio n. 18
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);
        }