Exemplo n.º 1
0
        public void UploadPost()
        {
            var  medium = new MediumApiClient(WeblogInfo);
            bool result = medium.GetUser();

            Assert.IsTrue(result, medium.ErrorMessage);

            var post = new MediumPost()
            {
                tags            = new string[] { "Markdown", "Test" },
                title           = "Test Post #" + DataUtils.GenerateUniqueId(),
                content         = "This is a **test post**.",
                contentFormat   = "markdown",
                publishStatus   = "draft",
                notifyFollowers = false,
                canonicalUrl    = "https://weblog.west-wind.com"
            };

            post = medium.PublishPost(post);

            Assert.IsNotNull(post.url, medium.ErrorMessage);
            Console.WriteLine(post.url);
            Console.WriteLine(post.id);
            ShellUtils.GoUrl(post.url);
        }
Exemplo n.º 2
0
        public void UploadPostToPublication()
        {
            var  medium = new MediumApiClient(WeblogInfo);
            bool result = medium.GetUser();

            Assert.IsTrue(result, medium.ErrorMessage);

            // make sure there is at least one publication available
            var pubs = medium.GetBlogs();

            Assert.IsNotNull(pubs, medium.ErrorMessage);

            string pubId = pubs.FirstOrDefault().BlogId as string;


            var post = new MediumPost()
            {
                tags            = new string[] { "Markdown", "Test" },
                title           = "Test Post #" + DataUtils.GenerateUniqueId(),
                content         = "This is a **test post**.",
                contentFormat   = "markdown",
                publishStatus   = "draft",
                notifyFollowers = false,
                canonicalUrl    = "https://weblog.west-wind.com"
            };

            post = medium.PublishPost(post, pubId);

            Assert.IsNotNull(post.url, medium.ErrorMessage);
            Console.WriteLine(post.url);
            Console.WriteLine(post.id);
            ShellUtils.GoUrl(post.url);
        }