728x90
728x170

기본 : 'WordPressPCL' Nuget  패키지 설치

코드 내용

using WordPressPCL;
using WordPressPCL.Models;

namespace WordPressPCLTest
{
    public partial class WordPressForm : Form
    {
        public WordPressForm()
        {
            InitializeComponent();
        }

        private async void getPostButton_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;

            WordPressClient client = new WordPressClient("https://wordpress주소.kr/wp-json/");

            IEnumerable<Post> postEnumerable = await client.Posts.GetAllAsync();

            int i = 1;

            foreach (Post post in postEnumerable.Reverse())
            {
                string title = post.Title.Rendered.Trim();

                this.textBox1.Text += $"[{i.ToString("000")}] {title + Environment.NewLine}";

                i++;
            }

            this.Cursor = Cursors.Default;
        }
    }
}

 

결과

 

728x90
그리드형
Posted by kjun
,