public void AddTag(string tag) { if (tag == null) { throw new ArgumentNullException("title"); } string op_string = GetXmlForTagging(tag); byte [] op_bytes = Encoding.UTF8.GetBytes(op_string); string url = GDataApi.GetPictureFeed(conn.User, album.UniqueID, UniqueID); HttpWebRequest request = conn.AuthenticatedRequest(url); request.ContentType = "application/atom+xml; charset=UTF-8"; request.Method = "POST"; Stream output_stream = request.GetRequestStream(); output_stream.Write(op_bytes, 0, op_bytes.Length); output_stream.Close(); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); using (Stream stream = response.GetResponseStream()) { StreamReader sr = new StreamReader(stream, Encoding.UTF8); sr.ReadToEnd(); } response.Close(); }
public PicasaAlbum CreateAlbum(string title, string description, AlbumAccess access, DateTime pubDate) { if (title == null) { throw new ArgumentNullException("title"); } if (description == null) { description = ""; } if (access != AlbumAccess.Public && access != AlbumAccess.Private) { throw new ArgumentException("Invalid value.", "access"); } // Check if pubDate can be in the past string url = GDataApi.GetPostURL(conn.User); if (url == null) { throw new UnauthorizedAccessException("You are not authorized to create albums."); } string op_string = GetXmlForCreate(title, description, pubDate, access); byte [] op_bytes = Encoding.UTF8.GetBytes(op_string); HttpWebRequest request = conn.AuthenticatedRequest(url); request.ContentType = "application/atom+xml; charset=UTF-8"; request.Method = "POST"; Stream output_stream = request.GetRequestStream(); output_stream.Write(op_bytes, 0, op_bytes.Length); output_stream.Close(); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); string received = ""; using (Stream stream = response.GetResponseStream()) { StreamReader sr = new StreamReader(stream, Encoding.UTF8); received = sr.ReadToEnd(); } response.Close(); XmlDocument doc = new XmlDocument(); doc.LoadXml(received); XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable); XmlUtil.AddDefaultNamespaces(nsmgr); XmlNode entry = doc.SelectSingleNode("atom:entry", nsmgr); return(new PicasaAlbum(conn, null, entry, nsmgr)); }