Example #1
0
        /// <summary>
        /// 关注动态
        /// </summary>
        /// <returns></returns>
        private async Task <List <GetAttentionUpdate> > GetUserAttentionUpdate()
        {
            try
            {
                using (HttpClient hc = new HttpClient())
                {
                    StorageFolder folder = ApplicationData.Current.LocalFolder;
                    StorageFile   file   = await folder.CreateFileAsync("us.bili", CreationCollisionOption.OpenIfExists);

                    ApiHelper.access_key = await FileIO.ReadTextAsync(file);

                    string url = string.Format("http://api.bilibili.com/x/feed/pull?access_key={0}&actionKey=appkey&appkey={1}&platform=wp&pn={2}&ps=30&ts={3}&type=0", ApiHelper.access_key, ApiHelper._appKey, 1, ApiHelper.GetTimeSpen);
                    url += "&sign=" + ApiHelper.GetSign(url);
                    HttpResponseMessage hr = await hc.GetAsync(new Uri(url));

                    hr.EnsureSuccessStatusCode();
                    string results = await hr.Content.ReadAsStringAsync();

                    //一层
                    GetAttentionUpdate model1 = JsonConvert.DeserializeObject <GetAttentionUpdate>(results);
                    if (model1.code == 0)
                    {
                        GetAttentionUpdate model2 = JsonConvert.DeserializeObject <GetAttentionUpdate>(model1.data.ToString());
                        return(model2.feeds);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            catch (Exception)
            {
                return(null);
            }
        }
Example #2
0
        /// <summary>
        /// 关注动态
        /// </summary>
        /// <returns></returns>
        private async Task <List <GetAttentionUpdate> > GetUserAttentionUpdate()
        {
            try
            {
                using (HttpClient hc = new HttpClient())
                {
                    StorageFolder folder = ApplicationData.Current.LocalFolder;
                    StorageFile   file   = await folder.CreateFileAsync("us.bili", CreationCollisionOption.OpenIfExists);

                    ApiHelper.access_key = await FileIO.ReadTextAsync(file);

                    string url             = $"http://api.bilibili.com/x/feed/pull?ps=10&type=0&pn={1}&_={ApiHelper.GetTimeSpen()}";
                    HttpResponseMessage hr = await hc.GetAsync(new Uri(url));

                    hr.EnsureSuccessStatusCode();
                    string results = await hr.Content.ReadAsStringAsync();

                    //一层
                    GetAttentionUpdate model1 = JsonConvert.DeserializeObject <GetAttentionUpdate>(results);
                    if (model1.Code == 0)
                    {
                        GetAttentionUpdate model2 = JsonConvert.DeserializeObject <GetAttentionUpdate>(model1.Data.ToString());
                        return(model2.Feeds);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                return(null);
            }
        }