README.md
#WordPressSharp# A C# client to interact with the WordPress XML-RPC API
##Install## I'm working on a Nuget package once I'm done mapping all the WP XML-RPC endpoints.
In the meantime, you'll have to clone, build, and add the DLL the ole fashioned way
##Config## Use your config file to for configuration settings:
xml
As an alternative you can use the
WordPressSiteConfig
class to store configuration settings.
#Examples#
##Create Post##
using (var client = new WordPressClient())
{
var post = new Post
{
PostType = "post",
Title = "My Awesome Post",
Content = "This is the content
",
PublishDateTime = DateTime.Now
};
var id = Convert.ToInt32(client.NewPost(post));
}
##Create Post Tag##
using (var client = new WordPressClient())
{
var termId = client.NewTerm(new Term
{
Name = "term test",
Description = "term description",
Slug = "term_test",
Taxonomy = "post_tag"
});
}
##Add feature image## You can add a feature image by using the
Data.CreateFromUrl
or Data.CreateFromFilePath
:string url = "https://unsplash.imgix.net/photo-1423683249427-8ca22bd873e0";
using (var client = new WordPressClient())
{
var post = new Post
{
PostType = "post",
Title = "New photo from Unsplash",
Content = "Check out this new picture from Unsplash.
",
PublishDateTime = DateTime.Now
};
var featureImage = Data.CreateFromUrl(url);
post.FeaturedImageId = client.UploadFile(featureImage).Id;
var id = Convert.ToInt32(client.NewPost(post));
}
#Tutorials# How to publish a post or page
#Dependencies# XML-RPC.net
#Resources# WordPress XML-RPC API
#Notes# Inspired by the POSSIBLE.WordPress.XmlRpcClient by markeverard
Комментариев нет:
Отправить комментарий