JoeBlogs WordPress Wrapper로 필드를 완성하려고합니다.JoeBlogs Wordpress Wrapper에 사용자 정의 필드를 추가하는 방법
내 코드는 다음과 같습니다
private void postToWordpress(string title, string postContent,string tags, string aioTitle)
{
string link = this.maskedTextBox1.Text;
string username = this.maskedTextBox2.Text;
string password = this.maskedTextBox3.Text;
var wp = new WordPressWrapper(link + "/xmlrpc.php", username, password);
var post = new Post();
post.Title = title;
post.Body = postContent;
post.Tags = tags.Split(',');
string[] cf = new CustomField(); //{ ID = "name", Key = "aiosp_title", Value = "All in One SEO Title" };
cf.ID = "name";
cf.Key = "aiosp_title";
cf.Value = "All in One SEO Title";
post.CustomFields[0] = cf;
wp.NewPost(post, false);
}
오류는이 라인에있다 :
post.CustomFields[0] = cf;
그리고는 다음과 같습니다
유형의 처리되지 않은 예외 'System.NullReferenceException' JoeBlogsWordpressWrapperTests.exe에서 발생했습니다.
추가 정보 : 개체 참조가 개체의 인스턴스로 설정되지 않았습니다.
그래서 WordPress에서 WordPress의 JoeBlogs WordPress Wrapper를 사용하여 C# 응용 프로그램의 사용자 정의 필드를 올바르게 추가/추가하는 방법은 무엇입니까?
실제로 구현되었으므로 여기를 읽으십시오. https://github.com/alexjamesbrown/JoeBlogs/pull/18 – caffeine
정확함. 일련의 시행 착오를 거쳐 내 대답을 업데이트하여 코드가 사용자 정의 필드를 저장하지 못하는 이유를 알아 냈습니다.위의 업데이트 된 답변보기 : – Shiva
이 두 가지 경우에 대해 알고 계셨습니까? 내가 Key = "aiosp_title"을 설정하면 훌륭하게 작동하며 게시물을 보낸 후 값을 데이터베이스에서 찾을 수 있지만 Key = "_aiosp_title "데이터베이스에 삽입되지 않았습니다. _에 무엇이 잘못 되었습니까? 왜 데이터베이스에 제출되지 않습니까? – caffeine