public static string CreateLinksPost(string content) { try { var md5 = content.ToMd5Hash(); var post = new Google.Apis.Blogger.v3.Data.Post { Title = md5, Content = content, }; var request = new PostsResource.InsertRequest(linksService, post, LinksBlogId) { IsDraft = false, }; var result = request.Execute(); if (result == null) { App.Logger.Error("Creating links post failed"); } else { var ret = rgx.Replace(result.Url, "http://links.epc-jav.com/"); return(ret); } } catch (Exception ex) { App.Logger.Error(ex.Message); } return(string.Empty); }
/// <summary> /// Initializes a new instance of the <see cref="AddBlogPostViewModel" /> class. /// </summary> public AddBlogPostViewModel() { _defaultSecretFileName = Properties.Settings.Default.DefaultSecretFileName; _blogRepostory = new BlogRepository(); _selectedBlog = null; _selectedPost = null; }
public static Post ToPost(Google.Apis.Blogger.v3.Data.Post gPost) { return(new Post() { Id = gPost.Id, Title = gPost.Title, Content = gPost.Content, Category = gPost.Labels?.Count > 0 ? gPost.Labels[0] : null, Author = gPost.Author, PublishedDate = gPost.Published?.ToString(new FormatProvider()), UpdatedDate = gPost.Updated?.ToString(new FormatProvider()), NumComments = gPost.Replies.TotalItems ?? 0, CommentUrl = gPost.Replies.SelfLink, PostUrl = "/Content/" + gPost.Id, ImageUrl = gPost.Images?.Count > 0 ? gPost.Images[0].Url : "/images/blog-1.jpg", Labels = gPost.Labels }); }
/** Creates a new blog entry and sends it to the specified Uri */ public static void PostNewDraftEntry(BlogPost blogPost) { try { // 建立 Post 物件資料 var post = new Google.Apis.Blogger.v3.Data.Post { Title = blogPost.Title, Content = "<div style='text-align: center;'>" + blogPost.ImageContent + " </div>" + string.Format("Download(Mega.nz & {0}) :<br /><hr class=\"more\"></hr>", UploadInfo.SecondHostName) + blogPost.LinksContent, }; // 送出 Insert Request var request = new PostsResource.InsertRequest(service, post, BlogId) { IsDraft = true }; var result = request.Execute(); if (result == null) { App.Logger.Error("Inserting blog blogPost failed"); } else { blogPost.LinksBackup.PostUri = result.SelfLink; } } catch (Exception ex) { App.Logger.Error(ex.Message); } finally { NLog.LogManager.GetLogger("LinksBackup"). Info(JsonConvert.SerializeObject(blogPost.LinksBackup, Formatting.Indented)); } }