C# 使用c在wordpress中以HTML形式发布博客文章#
我想在我的wordpress网站上发布一篇博客文章,但在c#应用程序中使用HTML代码创建它。原因是我在wordpress中为特定类型的帖子设置了一个模板(它有链接到URL等的按钮)。我该如何在c#中处理这件事呢。我使用XML-RPC包来创建新的博客文章,但是它只处理基本的事情,比如标题和内容。我的模板博客文章的HTML代码如下所示:C# 使用c在wordpress中以HTML形式发布博客文章#,c#,html,wordpress,winforms,xml-rpc,C#,Html,Wordpress,Winforms,Xml Rpc,我想在我的wordpress网站上发布一篇博客文章,但在c#应用程序中使用HTML代码创建它。原因是我在wordpress中为特定类型的帖子设置了一个模板(它有链接到URL等的按钮)。我该如何在c#中处理这件事呢。我使用XML-RPC包来创建新的博客文章,但是它只处理基本的事情,比如标题和内容。我的模板博客文章的HTML代码如下所示: <!-- wp:group --> <div class="wp-block-group"><div class
<!-- wp:group -->
<div class="wp-block-group"><div class="wp-block-group__inner-container"><!-- wp:heading {"level":4} -->
<h4>TITLE GOES HERE</h4>
<!-- /wp:heading -->
<!-- wp:spacer {"height":20} -->
<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->
<!-- wp:button {"backgroundColor":"luminous-vivid-orange"} -->
<div class="wp-block-button"><a class="wp-block-button__link has-background has-luminous-vivid-orange-background-color" href="https://www.wesbitelinkgoeshere.com">READ MORE</a></div>
<!-- /wp:button -->
按下按钮后,它将从表单上的2个文本框中成功发布新的博客文章,但我希望它使用HTML代码并从中创建博客文章,而不是以字符串内容发布
using System;
using System.Windows.Forms;
using CookComputing.XmlRpc;
public struct blogInfo
{
public string title;
public string description;
}
public interface IgetCatList
{
[CookComputing.XmlRpc.XmlRpcMethod("metaWeblog.newPost")]
string NewPage(int blogId, string strUserName,
string strPassword, blogInfo content, int publish);
}
namespace WordpressBlogTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnPost_Click(object sender, EventArgs e)
{
blogInfo newBlogPost = default(blogInfo);
newBlogPost.title = txtTitle.Text;
newBlogPost.description = txtPost.Text;
IgetCatList categories = (IgetCatList)XmlRpcProxyGen.Create(typeof(IgetCatList));
XmlRpcClientProtocol clientProtocol = (XmlRpcClientProtocol)categories;
clientProtocol.Url = "https://myblog.com/xmlrpc.php";
string result = null;
result = "";
try
{
result = categories.NewPage(1, "username", "password", newBlogPost, 1); MessageBox.Show("Posted to Blog successfullly! Post ID : " + result); txtPost.Text = "";
txtTitle.Text = "";
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}