public PostInfo GetPost(string postid) { var service = new Service(this.BlogConnectionInfo.MetaWeblogURL); var method = new MethodCall("metaWeblog.getPost"); method.Parameters.Add(postid); // notice this is the postid, not the blogid method.Parameters.Add(this.BlogConnectionInfo.Username); method.Parameters.Add(this.BlogConnectionInfo.Password); service.Cookies = this.BlogConnectionInfo.Cookies; var response = service.Execute(method); var param = response.Parameters[0]; var struct_ = (Struct)param; var postinfo = new PostInfo { //item.Categories PostID = struct_.Get <IntegerValue>("postid").ToString(), Description = struct_.Get <StringValue>("description").String, //item.Tags Link = struct_.Get("link", StringValue.NullString).String, DateCreated = struct_.Get <DateTimeValue>("dateCreated").Data, PermaLink = struct_.Get("permaLink", StringValue.NullString).String, PostStatus = struct_.Get("post_status", StringValue.NullString).String, Title = struct_.Get <StringValue>("title").String, UserID = struct_.Get("userid", StringValue.NullString).String }; var rawCats = struct_.Get <XmlRPC.Array>("categories"); rawCats.ToList().ForEach(i => { if (i is StringValue) { var cat = (i as StringValue).String; if (cat != "" && !postinfo.Categories.Contains(cat)) { postinfo.Categories.Add(cat); } } }); return(postinfo); }
public List <PostInfo> GetRecentPosts(int numposts) { var service = new Service(this.BlogConnectionInfo.MetaWeblogURL); var method = new MethodCall("metaWeblog.getRecentPosts"); method.Parameters.Add(this.BlogConnectionInfo.BlogID); method.Parameters.Add(this.BlogConnectionInfo.Username); method.Parameters.Add(this.BlogConnectionInfo.Password); method.Parameters.Add(numposts); service.Cookies = this.BlogConnectionInfo.Cookies; var response = service.Execute(method); var param = response.Parameters[0]; var array = (XmlRPC.Array)param; var items = new List <PostInfo>(); foreach (var value in array) { var struct_ = (Struct)value; var postinfo = new PostInfo { Title = struct_.Get("title", StringValue.NullString).String, DateCreated = struct_.Get <DateTimeValue>("dateCreated").Data, Link = struct_.Get("link", StringValue.NullString).String, PostID = struct_.Get("postid", StringValue.NullString).String, UserID = struct_.Get("userid", StringValue.NullString).String, CommentCount = struct_.Get <IntegerValue>("commentCount", 0).Integer, PostStatus = struct_.Get("post_status", StringValue.NullString).String, PermaLink = struct_.Get("permaLink", StringValue.NullString).String, Description = struct_.Get("description", StringValue.NullString).String }; items.Add(postinfo); } return(items); }
public string NewPost(PostInfo pi, IList <string> categories, bool publish = true) { return(NewPost(pi.Title, pi.Description, categories, publish, pi.DateCreated)); }