示例#1
0
 /// <summary>
 /// Posts an update to the given social media profiles.
 /// </summary>
 /// <param name="update">BufferUpdateCreate object describing the update to create.</param>
 /// <param name="profiles">List with all the social media profiles.</param>
 /// <returns>HttpResponse with a BufferUpdateCreating object describing the result of the operation.</returns>
 public async Task <HttpResponse <BufferUpdateCreation> > PostUpdate(BufferUpdateCreate update, IEnumerable <BufferProfile> profiles)
 {
     return(await PostUpdate(update, profiles.Select(p => p.Id)));
 }
示例#2
0
        /// <summary>
        /// Posts an update to the given social media profiles.
        /// </summary>
        /// <param name="update">BufferUpdateCreate object describing the update to create.</param>
        /// <param name="profileIds">List with all the social media profile ids.</param>
        /// <returns>HttpResponse with a BufferUpdateCreating object describing the result of the operation.</returns>
        public async Task <HttpResponse <BufferUpdateCreation> > PostUpdate(BufferUpdateCreate update, IEnumerable <string> profileIds)
        {
            ParameterCollection param = new ParameterCollection();

            foreach (var id in profileIds)
            {
                param.Add("profile_ids[]", id);
            }

            param.Add("text", update.Text);
            param.Add("shorten", update.Shorten.ToString().ToLower());
            param.Add("now", update.Now.ToString().ToLower());
            param.Add("top", update.Top.ToString().ToLower());
            param.Add("attachment", update.Attachment.ToString().ToLower());


            // schedule
            if (update.ScheduledAt != null && update.ScheduledAt != DateTime.MinValue)
            {
                param.Add("scheduled_at", update.ScheduledAtSeconds);
            }

            // media
            if (update.Media.Link != null && update.Media.Link.Trim() != "")
            {
                param.Add("media[link]", update.Media.Link);
            }

            if (update.Media.Description != null && update.Media.Description.Trim() != "")
            {
                param.Add("media[description]", update.Media.Description);
            }

            if (update.Media.Title != null && update.Media.Title.Trim() != "")
            {
                param.Add("media[title]", update.Media.Title);
            }

            if (update.Media.Picture != null && update.Media.Picture.Trim() != "")
            {
                param.Add("media[picture]", update.Media.Picture);
            }

            if (update.Media.Photo != null && update.Media.Photo.Trim() != "")
            {
                param.Add("media[photo]", update.Media.Photo);
            }

            if (update.Media.Thumbnail != null && update.Media.Thumbnail.Trim() != "")
            {
                param.Add("media[thumbnail]", update.Media.Thumbnail);
            }


            // retweet
            if (update.Retweet.TweetId != null && update.Retweet.TweetId.Trim() != "")
            {
                param.Add("retweet[tweet_id]", update.Retweet.TweetId);
            }

            if (update.Retweet.Comment != null && update.Retweet.Comment.Trim() != "")
            {
                param.Add("retweet[comment]", update.Retweet.Comment);
            }


            var req = CreateRequest("updates/create.json", HttpMethod.Post, param);

            return(await Execute <BufferUpdateCreation>(req));
        }