add a post / upload media to wordpress site throug

2019-04-15 21:18发布

Anyone know if its possible to add a post and upload images to a wordpress blog (self hosted) via a .net application?

I see i could use XML-RPC.net to talk with the wordpress XML-RPC interface, but i see really few documentation and samples around.

1条回答
Anthone
2楼-- · 2019-04-15 21:59

You can use JoeBlogs library to access the API. Using that, working with the blog is very simple:

var blog = new WordPressWrapper("https://svicktest.wordpress.com/xmlrpc.php", "svicktest", "mypassword");

byte[] imageData = …;

var image = blog.NewMediaObject(new MediaObject { bits = imageData, name = "Plane.jpg", type = "image/jpeg"});

blog.NewPost(new Post { title = "Hello!", description = "Hello world! <img src=\"" + image.url + "\" />" }, true);
查看更多
登录 后发表回答