Windows Live Plugins —— BatchPoster (發布到多個Blog)

來源:互聯網
上載者:User

CSDN和CnBlogs都不錯,兩個都想用著,所以就寫了這麼一個外掛程式。用途嘛,當然就是把文章發布到多個部落格上。

經常換Blog的或還沒決定用哪一個的朋友也可以用這個,免得遷來遷去~

特  性:在任意一個帳號編輯完文章,點擊“發送”後,將啟動外掛程式,提示使用者選擇帳號與目錄,然後將文章發布到指定的各個帳號。

:https://sourceforge.net/projects/livewriterpost/

總  結:

1、幾個比較常用的命名空間:

WindowsLive.Writer.Api;
WindowsLive.Writer.Passport;
WindowsLive.Writer.BlogClient;
WindowsLive.Writer.BlogClient.Clients;
WindowsLive.Writer.Extensibility.BlogClient;

2、使用WindowsLive.Writer.BlogClient.BlogSettings.GetBlogs函數擷取帳戶的列表,該函數返回一個BlogDescriptor數組。

3、WindowsLive.Writer.BlogClient.Blog對象包含一個帳戶的較完整資訊(包括目錄),使用建構函式建立對象即可。

4、使用BlogSettings.ForBlogId函數擷取指定帳戶的設定資訊。該函數返回一個BlogSettings對象。

5、WindowsLive.Writer.Api.PublishNotificationHook是“發布”操作的介面。

主要代碼:

public override bool OnPrePublish(System.Windows.Forms.IWin32Window dialogOwner, IProperties properties, IPublishingContext publishingContext, bool publish)        {            bool Result = false;            if (Posting) return true;            //選擇帳戶            if (DialogBlogSelect.ShowDialog() != System.Windows.Forms.DialogResult.OK)            {                Posting = false;                return false;            }            //排除當前帳戶            for (int i = 0; i < DialogBlogSelect.SelectedBlogs.Count; i++)            {                if (DialogBlogSelect.SelectedBlogs[i].ID.ToString() == publishingContext.AccountId)                {                    DialogBlogSelect.SelectedBlogs.RemoveAt(i);                    Result = true;                    break;                }            }            //發送到所選擇的帳戶            foreach (AccountItem blog in DialogBlogSelect.SelectedBlogs)            {                string str;                XmlDocument document;                BlogSettings settings = BlogSettings.ForBlogId(blog.ID.ToString());                IBlogClient client = BlogClientManager.CreateClient(settings);                string postId = client.NewPost(settings.HostBlogId, publishingContext.PostInfo as BlogPost, NullNewCategoryContext.Instance, true, out str, out document);                BlogPost post = client.GetPost(settings.HostBlogId, postId);                string permalink = post.Permalink;                if (!Uri.IsWellFormedUriString(permalink, UriKind.Absolute))                {                    permalink = new Uri(new Uri(settings.HomepageUrl), new Uri(post.Permalink, UriKind.Relative)).ToString();                }                ProcessStartInfo startInfo = new ProcessStartInfo(permalink);                startInfo.UseShellExecute = true;                Process.Start(startInfo);            }            Posting = false;            return Result;        }
其中有關發布的代碼參考了網上某位同學發布的一個外掛程式,是從其dll中Reflector出來的。不過我忘了出處了,Sorry!
趕工趕出來的,想完善的隨便改去好了。
本文即通過此外掛程式發布。
 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.