Exemple #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);
        }
Exemple #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 = 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);
        }
Exemple #3
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);
        }