private void SavePost(string title, string postContent) { //title = BlogFunUtlity.filterTitle(title); //StreamWriter sw = new StreamWriter(title + ".html"); //sw.Write(content); //sw.Close(); WordPressApi WordPress = new WordPressApi(); WordPress.Url = "http://www.zuihoude.com/xmlrpc.php"; string user = "******"; string password = "******"; WordpressPost content = new WordpressPost(); content.post_title = title; content.post_name = title; content.post_content = postContent; //content.post_excerpt = "asdf"; content.post_date = DateTime.Now; content.post_status = "draft"; content.post_type = "post"; //content.terms_names.category = new string[] { "Test" }; //CustomField[] cf = { new CustomField { key = "test", value = "1231233" } }; //content.custom_fields = cf; string PostID = WordPress.WpNewPost(0, user, password, content); publishLog.Add("Post published : " + PostID); hist.Add(title); Console.WriteLine("Post published : " + PostID); //Console.ReadLine(); }
private void ImportPost(WordpressPost p) { var header = new { Title = p.Title, Layout = "post", Categories = p.Categories, Tags = p.Tags }; var yamlHeader = string.Format("---\r\n{0}---\r\n\r\n", header.ToYaml()); var postContent = yamlHeader + p.Content; //todo would be nice to convert to proper md var fileName = string.Format(@"_posts\{0}-{1}.md", p.Published.ToString("yyyy-MM-dd"), p.PostName.Replace(' ', '-')); //not sure about post name fileSystem.File.WriteAllText(Path.Combine(pathToSite, fileName), postContent); }
private void ImportPost(WordpressPost p) { var header = new { title = p.Title, date = p.Published.ToString("yyyy-MM-dd"), layout = "post", categories = p.Categories, tags = p.Tags }; var yamlHeader = string.Format("---\r\n{0}---\r\n\r\n", header.ToYaml()); var postContent = yamlHeader + p.Content; //todo would be nice to convert to proper md var fileName = string.Format(@"_posts\{0}-{1}.md", p.Published.ToString("yyyy-MM-dd"), p.PostName.Replace(' ', '-')); //not sure about post name fileSystem.File.WriteAllText(Path.Combine(pathToSite, fileName), postContent); }
private JarbooPage ConvertDTOToObject(WordpressPost page) { return(ConvertDTOToObject(page.post)); }