Параметры метода wall.post
예제 #1
0
        /// <summary>
        /// Привести к типу VkParameters.
        /// </summary>
        /// <param name="p"> Параметры. </param>
        /// <returns> </returns>
        public static VkParameters ToVkParameters(WallPostParams p)
        {
            var result = new VkParameters
            {
                { "owner_id", p.OwnerId },
                { "friends_only", p.FriendsOnly },
                { "from_group", p.FromGroup },
                { "message", p.Message },
                { "attachments", p.Attachments },
                { "services", p.Services },
                { "signed", p.Signed },
                { "publish_date", p.PublishDate },
                { "lat", p.Lat },
                { "long", p.Long },
                { "place_id", p.PlaceId },
                { "post_id", p.PostId },
                { "captcha_sid", p.CaptchaSid },
                { "captcha_key", p.CaptchaKey },
                { "guid", p.Guid },
                { "mark_as_ads", p.MarkAsAds },
                { "close_comments", p.CloseComments }
            };

            return(result);
        }
예제 #2
0
        /// <summary>
        /// Привести к типу VkParameters.
        /// </summary>
        /// <param name="p">Параметры.</param>
        /// <returns></returns>
        internal static VkParameters ToVkParameters(WallPostParams p)
        {
            var result = new VkParameters
            {
                { "owner_id", p.OwnerId },
                { "friends_only", p.FriendsOnly },
                { "from_group", p.FromGroup },
                { "message", p.Message },
                { "attachments", p.Attachments },
                { "services", p.Services },
                { "signed", p.Signed },
                { "publish_date", p.PublishDate },
                { "lat", p.Lat },
                { "long", p.Long },
                { "place_id", p.PlaceId },
                { "post_id", p.PostId },
                { "captcha_sid", p.CaptchaSid },
                { "captcha_key", p.CaptchaKey }
            };

            return result;
        }
예제 #3
0
        public long Post(long? ownerId = null, bool friendsOnly = false, bool fromGroup = false,
            string message = null, IEnumerable<MediaAttachment> mediaAttachments = null, string url = null,
            IEnumerable<Services> services = null, bool signed = false, DateTime? publishDate = null,
            double? lat = null, double? @long = null, long? placeId = null, long? postId = null)
        {
            if (string.IsNullOrEmpty(message) && (mediaAttachments == null || !mediaAttachments.Any()) && string.IsNullOrEmpty(url))
                throw new ArgumentException("Message and attachments cannot be null or empty at the same time.");
            VkErrors.ThrowIfNumberIsNegative(() => placeId);
            VkErrors.ThrowIfNumberIsNegative(() => postId);
            if (lat.HasValue && (Math.Abs(lat.Value) > 90))
                throw new ArgumentOutOfRangeException("lat", lat, "lat must be at range from -90 to 90");
            if (@long.HasValue && (Math.Abs(@long.Value) > 180))
                throw new ArgumentOutOfRangeException("long", @long, "long must be at range from -90 to 90");

            var parameters = new WallPostParams
            {
                OwnerId = ownerId,
                FriendsOnly = friendsOnly,
                FromGroup = fromGroup,
                Message = message,
                Attachments = mediaAttachments,
                Services = services,
                Signed = signed,
                PublishDate = publishDate,
                Lat = lat,
                Long = @long,
                PlaceId = placeId,
                PostId = postId
            };

            return Post(parameters);
        }