/// <summary> /// 尝试获取Token过期时间 /// </summary> /// <param name="user">用户</param> /// <returns></returns> public static async Task <(bool, int)> GetExpiresIn(this User user) { if (user == null) { throw new ArgumentNullException(nameof(user)); } ResultInfo result; try { string json = await LoginApi.GetInfoAsync(user); if (string.IsNullOrEmpty(json)) { throw new ApiException(new Exception("获取Token过期时间失败,没有返回的数据。")); } result = JsonHelper.DeserializeJsonToObject <ResultInfo>(json); } catch (Exception ex) { throw new ApiException(ex); } if (result.Code == 0 && !string.IsNullOrEmpty(result.Data.Mid)) { return(true, result.Data.ExpiresIn); } else { return(false, 0); } }
/// <summary> /// 尝试获取Token过期时间 /// </summary> /// <param name="user">用户</param> /// <returns></returns> public static async Task <(bool, int)> GetExpiresIn(this User user) { if (user == null) { throw new ArgumentNullException(nameof(user)); } JObject result; try { string json = await LoginApi.GetInfoAsync(user); result = JObject.Parse(json); } catch (Exception ex) { throw new ApiException(ex); } if ((int)result["code"] == 0 && result["data"]["mid"] != null) { return(true, (int)result["data"]["expires_in"]); } else { return(false, 0); } }