Пример #1
0
        /// <summary>
        /// 关注动态
        /// </summary>
        /// <returns></returns>
        public async Task <List <GetAttentionUpdate> > GetUserAttentionUpdate(int PageNum)
        {
            if (IsLogin())
            {
                try
                {
                    wc = new WebClientClass();
                    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, PageNum, ApiHelper.GetTimeSpen);
                    url += "&sign=" + ApiHelper.GetSign(url);
                    string results = await wc.GetResults(new Uri(url));

                    //一层
                    GetAttentionUpdate model1 = JsonConvert.DeserializeObject <GetAttentionUpdate>(results);
                    if (model1.code == 0)
                    {
                        GetAttentionUpdate model2 = JsonConvert.DeserializeObject <GetAttentionUpdate>(model1.data.ToString());
                        try
                        {
                            if (PageNum == 1 && model2.feeds.Count != 0)
                            {
                                ApplicationDataContainer container = ApplicationData.Current.LocalSettings;
                                string s1 = "";
                                foreach (var item in model2.feeds)
                                {
                                    s1 += item.addition.aid + ",";
                                }
                                s1 = s1.Remove(s1.Length - 1);
                                container.Values["TsDt"] = s1;
                            }
                        }
                        catch (Exception)
                        {
                        }
                        return(model2.feeds);
                    }
                    else
                    {
                        return(null);
                    }
                }
                catch (Exception)
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Пример #2
0
        /// <summary>
        /// 关注动态
        /// </summary>
        /// <returns></returns>
        public async Task <List <GetAttentionUpdate> > GetUserAttentionUpdate(int PageNum)
        {
            if (IsLogin())
            {
                try
                {
                    using (HttpClient hc = new HttpClient())
                    {
                        HttpResponseMessage hr = await hc.GetAsync(new Uri("http://api.bilibili.com/x/feed/pull?jsonp=jsonp&ps=20&type=1&pn=" + PageNum));

                        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());
                            //三层
                            List <GetAttentionUpdate> ls = JsonConvert.DeserializeObject <List <GetAttentionUpdate> >(model2.feeds.ToString());
                            //四层
                            List <GetAttentionUpdate> lsModel = new List <GetAttentionUpdate>();
                            foreach (GetAttentionUpdate item in ls)
                            {
                                GetAttentionUpdate m = JsonConvert.DeserializeObject <GetAttentionUpdate>(item.addition.ToString());
                                m.page = model2.page;
                                lsModel.Add(m);
                            }
                            return(lsModel);
                        }
                        else
                        {
                            return(null);
                        }
                    }
                }
                catch (Exception)
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Пример #3
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?ps=10&type=0&pn={0}&_={1}", 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);
            }
        }