Exemplo n.º 1
0
        /// <summary>
        /// Publishes the given link to the authenticated user's feed.
        /// </summary>
        /// <param name="title">The title of the link</param>
        /// <param name="link">The link URL</param>
        /// <param name="comment">The initial comment for this entry</param>
        /// <param name="imageUrls">URLs of the thumbnails to be included with this entry</param>
        /// <param name="imageFiles">Paths to local image files to be included as thumbnails with this entry</param>
        /// <param name="via">The ID of the API client sending this request</param>
        /// <param name="audioUrls">URLs of the mp3 files to be included with this entry</param>
        /// <param name="room">The room to post this entry to</param>
        /// <returns>The new entry as returned by the server</returns>
        public Entry PublishLink(string title, string link, string comment, ThumbnailUrl[] imageUrls,
                                 ThumbnailFile[] imageFiles, string via, AudioUrl[] audioUrls, string room)
        {
            var postArguments = new SortedDictionary<string, string>();
            postArguments["title"] = title;
            if (link != null)
            {
                postArguments["link"] = link;
            }
            if (comment != null)
            {
                postArguments["comment"] = comment;
            }
            if (via != null)
            {
                postArguments["via"] = via;
            }
            if (room != null)
            {
                postArguments["room"] = room;
            }
            if (imageUrls != null)
            {
                for (int i = 0; i < imageUrls.Length; i++)
                {
                    postArguments["image" + i + "_url"] = imageUrls[i].Url;
                    if (imageUrls[i].Link != null)
                    {
                        postArguments["image" + i + "_link"] = imageUrls[i].Url;
                    }
                }
            }
            if (audioUrls != null)
            {
                for (int i = 0; i < audioUrls.Length; i++)
                {
                    postArguments["audio" + i + "_url"] = audioUrls[i].Url;
                    if (audioUrls[i].Title != null)
                    {
                        postArguments["audio" + i + "_title"] = audioUrls[i].Title;
                    }
                }
            }
            var fileAttachments = new SortedDictionary<string, string>();
            if (imageFiles != null)
            {

                for (int i = 0; i < imageFiles.Length; i++)
                {
                    fileAttachments["file" + i] = imageFiles[i].Path;
                    if (imageFiles[i].Link != null)
                    {
                        if( imageUrls == null || imageUrls[i] == null )
                        {
                            throw new Exception("imageUrls cannot be null");
                        }
                        postArguments["file" + i + "_link"] = imageUrls[i].Url;
                    }
                }
            }
            HttpWebResponse response = MakeRequest("/api/share", null, postArguments, fileAttachments);
            var document = new XmlDocument();
            document.Load(response.GetResponseStream());
            return (new Feed(document.DocumentElement))[0];
        }
Exemplo n.º 2
0
 /// <summary>
 /// Publishes the given link to the authenticated user's feed.
 /// </summary>
 /// <param name="title">The title of the link</param>
 /// <param name="link">The link URL</param>
 /// <param name="comment">The initial comment for this entry</param>
 /// <param name="imageUrls">URLs of the thumbnails to be included with this entry</param>
 /// <param name="imageFiles">Paths to local image files to be included as thumbnails with this entry</param>
 /// <param name="via">The ID of the API client sending this request</param>
 /// <param name="audioUrls">URLs of the mp3 files to be included with this entry</param>
 /// <returns>The new entry as returned by the server</returns>
 public Entry PublishLink(string title, string link, string comment, ThumbnailUrl[] imageUrls,
                          ThumbnailFile[] imageFiles, string via, AudioUrl[] audioUrls)
 {
     return PublishLink(title, link, comment, imageUrls, imageFiles, via, audioUrls, null);
 }