public override Folder GetFolders() { if (!IsAuthenticated) { throw new FilesOnlineAuthenticationException("You must login before you can view the file list."); } var str = string.Format(Constants.FileTreeRequest, 0, 0); var request = new HttpRequest(string.Format(Constants.BoxAPIGeneralUrl, User.Sid), Proxy); request.ContentType = "text/xml"; request.PostData = Utils.StrToByteArray(str); var document = new XmlDocument(); document.Load(request.GetResponse()); if (Utils.GetNodeTextString(document.SelectSingleNode("//status")).ToLower() != "listing_ok") { throw new FilesOnlineException( string.Format("Listing files failed. Response from Box.net was '{0}'", Utils.GetNodeTextString(document.SelectSingleNode("//status")).ToLower())); } var folderNode = document.SelectSingleNode("//folder"); return LoadFolderObject(folderNode, null); }
public override void Login(string email, string password) { if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password)) { throw new FilesOnlineException("You must supply both a Login/E-mail and Password."); } var str = string.Format(Constants.LoginRequest, email, password); var request = new HttpRequest(Constants.BoxAPILoginUrl, Proxy) { ContentType = "text/xml", PostData = Utils.StrToByteArray(str) }; var document = new XmlDocument(); document.Load(request.GetResponse()); if (Utils.GetNodeTextString(document.SelectSingleNode("//status")).ToLower() != "logged") { throw new FilesOnlineAuthenticationException( string.Format("Login failed. Response from Box.net was '{0}'", Utils.GetNodeTextString(document.SelectSingleNode("//status")).ToLower())); } User = new BoxNetUser { Sid = Utils.GetNodeTextString(document.SelectSingleNode("//user/sid")), AccessId = Utils.GetNodeTextInt(document.SelectSingleNode("//user/access_id")), Email = Utils.GetNodeTextString(document.SelectSingleNode("//user/email")), Free = Utils.GetNodeTextBool(document.SelectSingleNode("//user/free")), Login = Utils.GetNodeTextString(document.SelectSingleNode("//user/login")), SpaceAmount = Utils.GetNodeTextLong(document.SelectSingleNode("//user/space_amount")), SpaceUsed = Utils.GetNodeTextLong(document.SelectSingleNode("//user/space_used")), UserId = Utils.GetNodeTextInt(document.SelectSingleNode("//user/user_id")) }; }