0
私はC#でプログラムを書こうとしていますが、私は立ち往生しています。プログラムは、xmlrpc経由でwordpressに投稿を作成すると仮定します。投稿を正常に作成できますが、投稿のカスタムフィールドを作成する際に問題があります。だから、作成した投稿を開くと、カスタムフィールドは決してそこにはありません。私はあなたのいくつかは、教祖は、絶対に無力感を覚える:(私は今3日間立ち往生していますように私を助けることができるし、何をすべきかを把握カントを願っていC#XMLRPCカスタムフィールド
HERESにいくつかのコード:私は値を設定する方法をHERESに
public struct customField
{
public string key;
public string value;
}
public struct newPost
{
public string[] categories;
public string title;
public string description;
public string mt_excerpt;
public customField[] cf;
}
public interface IcreatePost
{
[CookComputing.XmlRpc.XmlRpcMethod("metaWeblog.newPost")]
string NewPost(int blogId, string strUserName,
string strPassword, newPost content, int publish);
}
呼び出されたオブジェクト
customField newCustomField2 = default(customField);
newCustomField2.key = "some data";
newCustomField2.value = "some data";
newPost newBlogPost = default(newPost);
newBlogPost.title = "Some Title";
newBlogPost.description = "Some Content";
newBlogPost.cf = new customField[] { newCustomField2 };
createPost(newBlogPost);
機能のために:
public void createPost(newPost np)
{
string postid;
icp = (IcreatePost)XmlRpcProxyGen.Create(typeof(IcreatePost));
clientProtocol = (XmlRpcClientProtocol)icp;
clientProtocol.Url = "http://127.0.0.1/xmlrpc.php";
try
{
postid = icp.NewPost(1, "admin", "1234", np, 1);
}
catch (Exception ex)
{
MessageBox.Show("createPost ERROR ->"+ ex.Message);
}
}
ありがとうございました!!!問題が解決しました:) – user1047463