Пример #1
0
        /// <summary>
        /// 获取文件目录
        /// </summary>
        /// <returns></returns>
        public List <BaiDuFile> GetFileDir()
        {
            if (!IsLogin)
            {
                return(null);
            }
            Dictionary <string, string> data = new Dictionary <string, string>();

            data.Add("app_id", SkyDrive_app_id.ToString());
            string url = "http://pan.baidu.com/api/list?";

            UrolsPage page = new UrolsPage();

            foreach (KeyValuePair <string, string> item in data)
            {
                url += item.Key + "=" + item.Value + "&";
            }
            page.Url           = url;
            page.RequestCookie = requestCookie;
            page.GET();

            string html   = page.Html;
            Regex  reg    = new Regex(@",.*,");
            Match  list_m = reg.Match(html);

            reg = new Regex(@"\{.*?\}");
            MatchCollection  mc       = reg.Matches(list_m.Value);
            List <BaiDuFile> fileList = new List <BaiDuFile>();
            BaiDuFile        fileItem;

            foreach (Match item in mc)
            {
                fileItem = new BaiDuFile();
                if (GetJsonValue("isdir", item.Value) == "1")
                {
                    fileItem.Type = 2;
                }
                else
                {
                    fileItem.Type = 1;
                }
                fileItem.Name = GetJsonValue("server_filename", item.Value);
                fileList.Add(fileItem);
            }
            return(fileList);
        }
Пример #2
0
        /// <summary>
        /// 获取Token,用于登陆用
        /// </summary>
        private void GetTokenAndCodeString()
        {
            string    url  = string.Format("https://passport.baidu.com/v2/api/?getapi&tpl=ik&apiver=v3&tt={0}&class=login", Utility.GetCurrentTimeStamp());
            UrolsPage page = new UrolsPage();

            page.Url           = url;
            page.RequestCookie = requestCookie;
            page.GET();
            requestCookie = page.RequestCookie;
            GetAllCookies(requestCookie);
            ResultData result = JsonConvert.DeserializeObject <ResultData>(page.Html);

            if (result.ErrInfo.no == "0")
            {
                Token = result.Data.Token;
                //CodeString = result.Data.CodeString;
            }
        }