private void GetDriveInfo() { if (!IsLogin) { DriveInfo = new DriveInfo(); } Dictionary <string, string> data = new Dictionary <string, string>(); data.Add("app_id", SkyDrive_app_id.ToString()); data.Add("checkexpire", "1"); data.Add("checkfree", "1"); data.Add("channel", "chunlei"); data.Add("clienttype", "0"); data.Add("web", "1"); string url = "http://pan.baidu.com/api/quota?"; 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; DriveInfo = JsonConvert.DeserializeObject <DriveInfo>(html); }
/// <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; fileItem.IsFolder = true; } else { fileItem.Type = 1; fileItem.IsFolder = false; } fileItem.Name = GetJsonValue("server_filename", item.Value); fileItem.Path = GetJsonValue("path", item.Value); fileList.Add(fileItem); } return(fileList); }
/// <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; } }
public List <Entry> List(Entry folder) { if (!IsLogin) { return(null); } Dictionary <string, string> data = new Dictionary <string, string>(); data.Add("app_id", SkyDrive_app_id.ToString()); if (folder != null && !String.IsNullOrEmpty(folder.path)) { data.Add("dir", folder.path); } string url = "http://pan.baidu.com/api/list?"; UrolsPage page = new UrolsPage(); foreach (KeyValuePair <string, string> item in data) { url += HttpUtility.UrlEncode(item.Key) + "=" + HttpUtility.UrlEncode(item.Value) + "&"; } page.Url = url; page.RequestCookie = requestCookie; page.GET(); string html = page.Html; Rootobject root = JsonConvert.DeserializeObject <Rootobject>(html); if (root.errno != 0) { return(null); } return(new List <Entry>(root.list)); //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; // fileItem.IsFolder = true; // } // else // { // fileItem.Type = 1; // fileItem.IsFolder = false; // } // fileItem.Name = GetJsonValue("server_filename", item.Value); // fileItem.Path = GetJsonValue("path", item.Value); // fileList.Add(fileItem); //} //return fileList; }