Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        /** 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));
            }
        }