/// <summary> /// 用户信息 /// </summary> /// <returns></returns> public async Task <GetLoginInfoModel> GetUserInfo() { if (IsLogin()) { try { using (HttpClient hc = new HttpClient()) { HttpResponseMessage hr = await hc.GetAsync(new Uri("http://api.bilibili.com/userinfo?mid=" + Uid + "&rd=" + new Random().Next(1, 1000))); hr.EnsureSuccessStatusCode(); string results = await hr.Content.ReadAsStringAsync(); GetLoginInfoModel model = new GetLoginInfoModel(); model = JsonConvert.DeserializeObject <GetLoginInfoModel>(results); JObject json = JObject.Parse(model.level_info.ToString()); model.current_level = (int)json["current_level"]; //model.current_level = "LV" + json["current_level"].ToString(); return(model); } } catch (Exception) { return(null); } } else { return(null); } }
protected override void OnNavigatedTo(NavigationEventArgs e) { bg.Color = ((SolidColorBrush)this.Frame.Tag).Color; GetLoginInfoModel model = e.Parameter as GetLoginInfoModel; dt_Date.MaxYear = new DateTime(2015, 12, 31); dt_Date.Date = Convert.ToDateTime(model.birthday); txt_UserName.Text = model.name; txt_Sign.Text = model.sign; switch (model.sex) { case "保密": rb_B.IsChecked = true; break; case "男": rb_N.IsChecked = true; break; case "女": rb_V.IsChecked = true; break; default: break; } }
private async Task GetUserInfo() { UserClass getUser = new UserClass(); GetLoginInfoModel model = new GetLoginInfoModel(); if (Uid.Length != 0) { model = await getUser.GetUserInfo(Uid); } else { model = await getUser.GetUserInfo(); } if (model.approve) { txt_RZ.Visibility = Visibility.Visible; } else { txt_RZ.Visibility = Visibility.Collapsed; } grid_Info.DataContext = model; if (model.current_level <= 3) { bor_Level.Background = new SolidColorBrush(new Windows.UI.Color() { R = 48, G = 161, B = 255, A = 200 }); } else { if (model.current_level <= 6) { bor_Level.Background = new SolidColorBrush(new Windows.UI.Color() { R = 255, G = 48, B = 48, A = 200 }); } else { bor_Level.Background = new SolidColorBrush(new Windows.UI.Color() { R = 255, G = 199, B = 45, A = 200 }); } } }
public async Task <GetLoginInfoModel> GetUserInfo(string uid) { try { wc = new WebClientClass(); string url = string.Format("http://api.bilibili.com/userinfo?access_key={0}&appkey={1}&mid={2}", ApiHelper.access_key, ApiHelper._appKey, uid); url += "&sign=" + ApiHelper.GetSign(url); string results = await wc.GetResults(new Uri(url)); GetLoginInfoModel model = JsonConvert.DeserializeObject <GetLoginInfoModel>(results); return(model); } catch (Exception) { return(null); } }
public async Task <GetLoginInfoModel> GetUserInfo(string uid) { try { WebClientClass wc = new WebClientClass(); string results = await wc.GetResults(new Uri("http://api.bilibili.com/userinfo?mid=" + uid + "&rd=" + new Random().Next(1, 1000))); GetLoginInfoModel model = new GetLoginInfoModel(); model = JsonConvert.DeserializeObject <GetLoginInfoModel>(results); JObject json = JObject.Parse(model.level_info.ToString()); model.current_level = (int)json["current_level"]; //model.current_level = "LV" + json["current_level"].ToString(); return(model); } catch (Exception) { return(null); } }
//private async Task GetSubInfo() //{ // try // { // user_GridView_Submit.ItemsSource = null; // WebClientClass wc = new WebClientClass(); // txt_Load.IsEnabled = false; // txt_Load.Content = "加载中..."; // string results = await wc.GetResults(new Uri("http://space.bilibili.com/ajax/member/getSubmitVideos?mid=" + Uid + "&pagesize=20&page=1")); // //一层 // GetUserSubmit model1 = JsonConvert.DeserializeObject<GetUserSubmit>(results); // //二层 // GetUserSubmit model2 = JsonConvert.DeserializeObject<GetUserSubmit>(model1.data.ToString()); // //三层 // List<GetUserSubmit> lsModel = JsonConvert.DeserializeObject<List<GetUserSubmit>>(model2.vlist.ToString()); // user_GridView_Submit.ItemsSource = lsModel; // } // catch (Exception) // { // } // finally // { // if (user_GridView_Submit.Items.Count == 0) // { // DT_SUB.Visibility = Visibility.Visible; // } // else // { // DT_SUB.Visibility = Visibility.Collapsed; // } // } //} public async Task <GetLoginInfoModel> GetUserInfo() { try { wc = new WebClientClass(); //http://account.bilibili.com/api/myinfo/v2?access_key={0}&appkey={1}&platform=ios&ts={2}&type=json string url = string.Format("http://account.bilibili.com/api/myinfo/v2?access_key={0}&appkey={1}&platform=ios&ts={2}&type=json", ApiHelper.access_key, ApiHelper._appKey, ApiHelper.GetTimeSpen); url += "&sign=" + ApiHelper.GetSign(url); string results = await wc.GetResults(new Uri(url)); GetLoginInfoModel model = JsonConvert.DeserializeObject <GetLoginInfoModel>(results); UserClass.AttentionList = model.attentions; return(model); } catch (Exception) { throw; } }
public async Task <GetLoginInfoModel> GetUserInfo(string uid) { try { wc = new WebClientClass(); // string url = string.Format("http://app.bilibili.com/x/v2/space?access_key={0}&appkey={1}&platform=wp&ps=10&ts={2}000&vmid={3}&build=411005&mobi_app=android", ApiHelper.access_key, ApiHelper._appKey, ApiHelper.GetTimeSpen, uid); //string url = string.Format("http://api.bilibili.com/userinfo?access_key={0}&appkey={1}&mid={2}", ApiHelper.access_key, ApiHelper._appKey, uid); url += "&sign=" + ApiHelper.GetSign(url); string results = await wc.GetResults(new Uri(url)); GetLoginInfoModel model = JsonConvert.DeserializeObject <GetLoginInfoModel>(results); return(model.data.card); } catch (Exception) { return(null); } }
private async Task UserInfo() { try { GetLoginInfoModel model = new GetLoginInfoModel(); if (Uid.Length != 0) { model = await GetUserInfo(Uid); // http://i0.hdslb.com/ } else { model = await GetUserInfo(); } if (model.approve) { if (model.official_verify.type != -1) { txt_RZ.Text = model.official_verify.desc; } txt_RZ.Visibility = Visibility.Visible; } else { txt_RZ.Visibility = Visibility.Collapsed; } grid_Info.DataContext = model; if (model.level_info.current_level <= 3) { bor_Level.Background = new SolidColorBrush(new Windows.UI.Color() { R = 48, G = 161, B = 255, A = 200 }); } else { if (model.current_level <= 6) { bor_Level.Background = new SolidColorBrush(new Windows.UI.Color() { R = 255, G = 48, B = 48, A = 200 }); } else { bor_Level.Background = new SolidColorBrush(new Windows.UI.Color() { R = 255, G = 199, B = 45, A = 200 }); } } if (model.vip.vipType != 0) { bor_Vip.Visibility = Visibility.Visible; } else { bor_Vip.Visibility = Visibility.Collapsed; } //if (model!=null&&model.toutu.Length!=0) //{ // img_bg.ImageSource = new BitmapImage(new Uri("http://i0.hdslb.com/"+model.toutu)); //} SettingHelper settings = new SettingHelper(); if (settings.SettingContains("UserWebTT")) { if ((bool)settings.GetSettingValue("UserWebTT")) { GetBg(); } else { img_bg.ImageSource = new BitmapImage(new Uri("ms-appx:///Assets/bg1.png")); } } else { settings.SetSettingValue("UserWebTT", false); img_bg.ImageSource = new BitmapImage(new Uri("ms-appx:///Assets/bg1.png")); } page = 1; MaxPage = 0; list_AUser.Items.Clear(); GetUserAttention(page); } catch (Exception) { messShow.Show("读取用户信息失败", 2000); // throw; } }