using System; namespace RSSBlogAPI { using CommunityServer; /// <summary> /// Blog API for Community Server /// </summary> public class CommunityServerAPI : BlogAPIBase { public override bool HasCategories { get { return true; } } public override bool HasBlogId { get { return false; } } public override string EngineName { get { return ".TEXT SimpleBlogService"; } } public override string HelpText { get { return ".Text Blog sites"; } } public override void Test() { this.GetCategories(); } /// <summary> /// Retrieve categories by calling the SimpleBlogService webservice /// </summary> /// <returns></returns> public override Category [] GetCategories() { string [] categories = this.GetService().GetPostCategories( ); Category [] output = new Category [ categories.Length ]; for( int i=0; i<categories.Length; i++ ) output[i] = new Category( 0, string.Empty, categories[i] ); return output; } private BlogService GetService() { BlogCredentials credentials = new BlogCredentials(); credentials.Blogname = this.BlogId; credentials.Password = this.Password; credentials.Username = this.Username; BlogService svc = new BlogService(); svc.Url = this.Url; svc.Proxy = this.ProxyServer; svc.BlogCredentialsValue = credentials; return svc; } /// <summary> /// Post a blog entry by calling simple blog service /// </summary> /// <param name="post"></param> /// <returns></returns> public override string PostItem( Post log ) { string [] cats = new string[ log.Categories.Length ]; for( int i=0; i<log.Categories.Length; i++ ) cats[i] = log.Categories[i].Title; BlogPost post = new BlogPost(); post.Body = log.Text; post.Categories = cats; post.Date = log.Date; post.DisplayOnHome = true; post.EnableComments = true; post.EnableRatings = true; post.EnableTrackbacks = true; post.Excerpt = post.Title; post.IsPublished = true; post.ModerateComments = true; post.Name = this.Username; post.SydicateRoot = true; post.Syndicate = true; post.Title = log.Title; return this.GetService().Create( post ).ToString(); } } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)