http://rpc.cnblogs.com/metaweblog/webenh

在网上闲逛,突然对博客的接口感兴趣,经考察,多数博客都对metaWeblog Api 提供了支持,虽然windows live writer是好用,不过出于对这个接口的好奇,也想自己做个能发博客的小工具.

到处浏览资料,用了一个下午终于成功发布了一篇简陋版博客:)。其实很简单,方法对了很快就连上了。

MetaWeblog API中文说明

1、什么是MetaWeblog API?

MetaWeblog API(MWA)是一个Blog程序接口标准,允许外部程序来获取或者设置Blog的文字和熟悉。他建立在XMLRPC接口之上,并且已经有了很多的实现。

2、基本的函数规范

有三个基本的函数规范:

metaWeblog.newPost (blogid, username, password, struct, publish) 返回一个字符串,可能是Blog的ID。
metaWeblog.editPost (postid, username, password, struct, publish) 返回一个Boolean值,代表是否修改成功。
metaWeblog.getPost (postid, username, password) 返回一个Struct。

其中blogid、username、password分别代表Blog的id(注释:如果你有两个Blog,blogid指定你需要编辑的blog)、用户名和密码。

一、要引用的DLL【网上提供的示例多包含了这个DLL】

二、要实现的数据结构

MetaWeblogCode【如不想看代码请自行折叠】


  1 using System;
  2 using CookComputing.XmlRpc;
  3 
  4 namespace metaWeblogTest
  5 {
  6 
  7     #region 微软MSN网站 使用的 MetaWeblog API.
  8     /// 这个结构代表用户的博客基本信息
  9     /// </summary>
10     [XmlRpcMissingMapping(MappingAction.Ignore)]
11     public struct UserBlog
12     {
13         public string url;
14         public string blogid;
15         public string blogName;
16     }
17 
18 
19     /// <summary> 
20     /// 这个结构代表用户信息
21     /// </summary> 
22     [XmlRpcMissingMapping(MappingAction.Ignore)]
23     public struct UserInfo
24     {
25         public string url;
26         public string blogid;
27         public string blogName;
28         public string firstname;
29         public string lastname;
30         public string email;
31         public string nickname;
32     }
33 
34 
35     /// <summary> 
36     /// 这个结构代表博客分类信息
37     /// 这后面的getCategories()方法会取到CATEGORY数据。
38     /// </summary> 
39     [XmlRpcMissingMapping(MappingAction.Ignore)]
40     public struct Category
41     {
42         public string description;
43         public string title;
44     }
45 
46     /// <summary>  47     /// 这个结构代表博客( 文章 )信息。 48     /// 这后面的 editPost()方法, getRecentPosts()方法 和 getPost()方法 会取倒POST数据 .  49     /// </summary>  50     [XmlRpcMissingMapping(MappingAction.Ignore)] 51     public struct Post 52     { 53         public DateTime dateCreated; 54         public string description; 55         public string title; 56         public string postid; 57         public string[] categories; 58     } 59     #endregion 60  61  62     #region 网站:http://msdn.microsoft.com/en-us/library/aa905670.aspx 63     ///// <summary>  64     ///// 微软MSN网站 使用的 MetaWeblog API.  65     ////  网站:http://msdn.microsoft.com/en-us/library/aa905670.aspx 66     ///// </summary>  67     public class M_MetaWeblog : XmlRpcClientProtocol 68     { 69  70  71         /// <summary>  72         /// Returns the most recent draft and non-draft blog posts sorted in descending order by publish date.  73         /// </summary>  74         /// <param name="blogid"> This should be the string MyBlog, which indicates that the post is being created in the user’s blog. </param>  75         /// <param name="username"> The name of the user’s space. </param>  76         /// <param name="password"> The user’s secret word. </param>  77         /// <param name="numberOfPosts"> The number of posts to return. The maximum value is 20. </param>  78         /// <returns></returns>  79         /// TODO:得到最近发布的帖子 80         [XmlRpcMethod("metaWeblog.getRecentPosts")] 81         public Post[] getRecentPosts( 82         string blogid, 83         string username, 84         string password, 85         int numberOfPosts) 86         { 87  88             return (Post[])this.Invoke("getRecentPosts", new object[] { blogid, username, password, numberOfPosts }); 89         } 90  91  92         /// <summary>  93         /// Posts a new entry to a blog.  94         /// </summary>  95         /// <param name="blogid"> This should be the string MyBlog, which indicates that the post is being created in the user’s blog. </param>  96         /// <param name="username"> The name of the user’s space. </param>  97         /// <param name="password"> The user’s secret word. </param>  98         /// <param name="post"> A struct representing the content to update. </param>  99         /// <param name="publish"> If false, this is a draft post. </param>  100         /// <returns> The postid of the newly-created post. </returns>  101         /// TODO:增加一个最新的帖子 102         [XmlRpcMethod("metaWeblog.newPost")] 103         public string newPost( 104         string blogid, 105         string username, 106         string password, 107         Post content, 108         bool publish) 109         { 110  111             return (string)this.Invoke("newPost", new object[] { blogid, username, password, content, publish }); 112         } 113  114         /// <summary>  115         /// Edits an existing entry on a blog.  116         /// </summary>  117         /// <param name="postid"> The ID of the post to update. </param>  118         /// <param name="username"> The name of the user’s space. </param>  119         /// <param name="password"> The user’s secret word. </param>  120         /// <param name="post"> A struct representing the content to update. </param>  121         /// <param name="publish"> If false, this is a draft post. </param>  122         /// <returns> Always returns true. </returns>  123         /// TODO:更新一个帖子 124         [XmlRpcMethod("metaWeblog.editPost")] 125         public bool editPost( 126         string postid, 127         string username, 128         string password, 129         Post content, 130         bool publish) 131         { 132  133             return (bool)this.Invoke("editPost", new object[] { postid, username, password, content, publish }); 134         } 135  136         /// <summary>  137         /// Deletes a post from the blog.  138         /// </summary>  139         /// <param name="appKey"> This value is ignored. </param>  140         /// <param name="postid"> The ID of the post to update. </param>  141         /// <param name="username"> The name of the user’s space. </param>  142         /// <param name="password"> The user’s secret word. </param>  143         /// <param name="post"> A struct representing the content to update. </param>  144         /// <param name="publish"> This value is ignored. </param>  145         /// <returns> Always returns true. </returns>  146         /// TODO:删除一个帖子 147         [XmlRpcMethod("blogger.deletePost")] 148         public bool deletePost( 149         string appKey, 150         string postid, 151         string username, 152         string password, 153         bool publish) 154         { 155  156             return (bool)this.Invoke("deletePost", new object[] { appKey, postid, username, password, publish }); 157         } 158  159  160         /// <summary>  161         /// Returns information about the user’s space. An empty array is returned if the user does not have a space.  162         /// </summary>  163         /// <param name="appKey"> This value is ignored. </param>  164         /// <param name="postid"> The ID of the post to update. </param>  165         /// <param name="username"> The name of the user’s space. </param>  166         /// <param name="password"></param> 167         /// <returns>
An array of structs that represents each of the user’s blogs. The array
will contain a maximum of one struct, since a user can only have a
single space with a single blog. </returns>  168         /// TODO:得到用户的博客清单 169         [XmlRpcMethod("blogger.getUsersBlogs")] 170         public UserBlog[] getUsersBlogs( 171         string appKey, 172         string username, 173         string password) 174         { 175  176             return (UserBlog[])this.Invoke("getUsersBlogs", new object[] { appKey, username, password }); 177         } 178  179         /// <summary>  180         /// Returns basic user info (name, e-mail, userid, and so on).  181         /// </summary>  182         /// <param name="appKey"> This value is ignored. </param>  183         /// <param name="postid"> The ID of the post to update. </param>  184         /// <param name="username"> The name of the user’s space. </param>  185         /// <param name="password"></param> 186         /// <returns> A struct containing profile information about the user.  187         /// Each struct will contain the following fields: nickname, userid, url, e-mail,  188         /// lastname, and firstname. </returns>  189         /// TODO:得到用户信息 190         [XmlRpcMethod("blogger.getUserInfo")] 191         public UserInfo getUserInfo( 192         string appKey, 193         string username, 194         string password) 195         { 196  197             return (UserInfo)this.Invoke("getUserInfo", new object[] { appKey, username, password }); 198         } 199  200  201         /// <summary>  202         /// Returns a specific entry from a blog.  203         /// </summary>  204         /// <param name="postid"> The ID of the post to update. </param>  205         /// <param name="username"> The name of the user’s space. </param>  206         /// <param name="password"> The user’s secret word. </param>  207         /// <returns> Always returns true. </returns>  208         /// TODO:获取一个帖子 209         [XmlRpcMethod("metaWeblog.getPost")] 210         public Post getPost( 211         string postid, 212         string username, 213         string password) 214         { 215  216             return (Post)this.Invoke("getPost", new object[] { postid, username, password }); 217         } 218  219         /// <summary>  220         /// Returns the list of categories that have been used in the blog.  221         /// </summary>  222         /// <param name="blogid"> This should be the string MyBlog, which indicates that the post is being created in the user’s blog. </param>  223         /// <param name="username"> The name of the user’s space. </param>  224         /// <param name="password"> The user’s secret word. </param>  225         /// <returns>
An array of structs that contains one struct for each category. Each
category struct will contain a description field that contains the name
of the category. </returns>  226         /// TODO:得到博客分类 227         [XmlRpcMethod("metaWeblog.getCategories")] 228         public Category[] getCategories( 229         string blogid, 230         string username, 231         string password) 232         { 233  234             return (Category[])this.Invoke("getCategories", new object[] { blogid, username, password }); 235         } 236     } 237     #endregion 238 } 239 

三、图示【调用API发送第一篇简单博客】

——————————————————————————————————————————

资源链接:

http://www.xmlrpc.com/spec   英文的xml-rpc规范
RFC: MetaWeblog API   MetaWeblog API 规范

http://www.duduwolf.com/post/41.asp  中文翻译的xml-rpc规范(感谢翻译者:滴水)

http://www.XML-RPC.Net XML-RPC的.NET 实现,其中有最新.net2.0的XML-RPC实现的下载

MetaWeblogAPI and MSN Spaces  MSDN上关于MetaWeblog API及MSN Spaces接口的说明及.NET示例

MetaWeblog API调用的更多相关文章

  1. 转 MetaWeblog API 编写

    如今,许多人都熟悉个人和公司或业界主办的博客.后者明显成为了传统公司和行业网站的下一代新兴产物.博客的内容涉及从简洁的特制产品公告和公共关系到实用且深刻的主题探索,这些主题可能对公司的产品或行业的未来 ...

  2. MetaWebLog API — 一个多平台文章同步的思路

    文章选自我的博客:https://blog.ljyngup.com/archives/578.html/ 起因 为了给博客带来流量,我在CSDN,博客园,简书上开通了账号并且把博客里的一些可以发布的文 ...

  3. Vue.js——使用$.ajax和vue-resource实现OAuth的注册、登录、注销和API调用

    概述 上一篇我们介绍了如何使用vue resource处理HTTP请求,结合服务端的REST API,就能够很容易地构建一个增删查改应用.这个应用始终遗留了一个问题,Web App在访问REST AP ...

  4. 信鸽推送 .NET (C#) 服务端 SDK rest api 调用库(v1.2)

    信鸽推送 .NET  服务端 SDK rest api 调用库-介绍 该版本是基于信鸽推送v2版本的时候封装的,先拿出来与大家分享,封装还还凑合,不依赖其他http调用件,唯一依赖json序列化dll ...

  5. iOS 版 MWeb 发布到自建 Wordpress 和 Metaweblog API 使用指南

    MWeb 的发布服务的使用方法是先增加发布服务,再使用.在 iOS 中,要增加发布服务,可以在首页中,点左上角的 "设置" 按钮,进入设置界面,并滑动到底部,就会看到增加发布服务的 ...

  6. MWeb 1.3.7 发布!增加发布到 Wordpress 等支持 MetaWeblog API 的服务,如:Wordpress 博客、新浪博客、cnblogs、oschina。

    MWeb 1.3.7 版的新功能 增加发布到 Wordpress 等支持 Metaweblog API 的服务,目前经测试过的有: Wordpress 博客.新浪博客.cnblogs.oschina. ...

  7. xmlrpc实现bugzilla api调用(无会话保持功能,单一接口请求)

    xmlrpc实现bugzilla4   xmlrpc api调用(无会话保持功能,单一接口请求),如需会话保持,请参考我的另外一篇随笔(bugzilla4的xmlrpc接口api调用实现分享: xml ...

  8. FormatMessage与GetLastError配合使用,排查windows api调用过程中的错误

    前一段时间在学习windows api调用过程中,遇到过一些调用错误或者程序没能显示预期的结果,或者直接出现vc运行时错误. 这对新手来说是司空见惯的事,因为不太熟悉难免会出错,出错的信息如果能显示很 ...

  9. 基于Metaweblog API 接口一键发布到国内外主流博客平台

    之前的生活 之前一直使用evenote写博客和日志,其实还是挺方便的.但是我一直都希望能够同步到国内的博客和国外的blogspot等主流博客平台.而强大everote只提供了facebook.twit ...

随机推荐

  1. Entity Framework 实体框架的形成之旅--Code First的框架设计(5)

    在前面几篇介绍了Entity Framework 实体框架的形成过程,整体框架主要是基于Database First的方式构建,也就是利用EDMX文件的映射关系,构建表与表之间的关系,这种模式弹性好, ...

  2. asp.net各种cookie代码和解析

    Cookie是一段文本信息,在客户端存储 Cookie 是 ASP.NET 的会话状态将请求与会话关联的方法之一.Cookie 也可以直接用于在请求之间保持数据,但数据随后将存储在客户端并随每个请求一 ...

  3. CSS使图片变灰

    为了悼念,各大网站都纷纷将自己的站点颜色调灰,就连图片也一样,到底如何实现的呢,请看下面的代码. 〈img src="http://hovertree.com/hvtimg/201512/f ...

  4. C# ~ 由 IDisposable 到 GC

    IDisposable 接口 1. 托管资源和非托管资源   ·  托管资源  a.  CLR 控制和管理的内存资源,如程序中在 Heap 上分配的对象.作用域内的变量等:  b.  GC 机制实现自 ...

  5. .NET使用ZXing.NET生成中间带图片的二维码

    很久之前就有写这样的代码了,只是一直没记录下来,偶然想写成博客. 把之前的代码封装成函数,以方便理解以及调用. 基于开源的 ZXing.NET 组件,代码如下: 先添加对ZXing.NET的引用,然后 ...

  6. Oracle数据库,用户的创建及表的创建

    安装完成之后,打开浏览器,输入https://127.0.0.1:1158/em 链接至登录数据库界面 用户名:sys     口令为安装时设置的密码(一定牢记) 链接身份为:SYSDBA(以系统管理 ...

  7. InfluxDB学习之InfluxDB的基本概念

    InfluxDB与传统数据库在概念上有许多的不同,本文就给大家介绍下InfluxDB中的一些基本概念,更多InfluxDB详细教程请看:InfluxDB系列学习教程目录 InfluxDB技术交流群:5 ...

  8. windows / linux系统中,端口被占用解决方法

    一.在windows操作系统中,查询端口占用和清除端口占用的程序 提升权限后用:netstat -b或用 1.查询端口占用的进程ID 点击"开始"-->"运行&qu ...

  9. java多线程功力

    一.操作系统中线程和进程的概念 现在的操作系统是多任务操作系统.多线程是实现多任务的一种方式.多线程编程可以使程序具有两条或两条以上的并发执行线索. 进程是指一个内存中运行的应用程序,每个进程都有自己 ...

  10. JavaScript for循环 闭包 【转】

    个网友问了个问题,如下的html,为什么每次输出都是5,而不是点击每个p,就alert出对应的1,2,3,4,5. <html > <head> <meta http-e ...