用户工具

站点工具


tools:metaweblog
blogger.deletePost —— 删除文章
blogger.getUsersBlogs —— 获取用户博客信息
metaWeblog.editPost —— 编辑文章
metaWeblog.getCategories —— 获取用户博客分类
metaWeblog.getPost —— 获取文章
metaWeblog.getRecentPosts —— 获取最近的文章
metaWeblog.newMediaObject —— 添加媒体对象(图片等)
metaWeblog.newPost —— 添加文章
wp.newCategory —— 添加目录

1,src/main/resources/org/apache/xmlrpc/webserver/XmlRpcServlet.properties

blogger=mov.metaweblog.service.MetaWebLogService
metaWeblog=mov.metaweblog.service.MetaWebLogService
wp=mov.metaweblog.service.MetaWebLogService

2,web.xml

  <servlet>
      <servlet-name>XmlRpcServlet</servlet-name>
      <servlet-class>org.apache.xmlrpc.webserver.XmlRpcServlet</servlet-class>
      <init-param>
        <param-name>enabledForExtensions</param-name>
        <param-value>true</param-value>
      </init-param>
  </servlet>
  <servlet-mapping>
      <servlet-name>XmlRpcServlet</servlet-name>
      <url-pattern>/metaweblog</url-pattern>
  </servlet-mapping>

3,MetaWebLogService

搜索博客:List<Map<String, String» getUsersBlogs(String key, String username, String password) 查询分类:List<Map<String, String» getCategories(String blogid, String username, String password) 添加分类:String newCategory(String blogId, String username, String password,Map<String, String> category) 发布博客:String newPost(String blogid, String username, String password,Map<String, Object> post, boolean publish) 删除博客:boolean deletePost(String appKey, String postid, String username, String password, boolean publish) 修改博客:boolean editPost(String postid, String username, String password, Map<String, Object> post, boolean publish) 获取博客:Map<String, Object> getPost(String postid, String username, String password)

//serverurl
http://rpc.cnblogs.com/metaweblog/xingqi
https://my.oschina.net/action/xmlrpc
http://localhost:8080/metaweblog-demo/metaweblog
http://localhost:8081/metaweblog
  • Post
    • dateCreated Date,创建日期
    • description String,博客内容html
    • title String,标题
request({
    url: url,
    method: "POST",
    json: true,
    headers: {
        "content-type": "application/json",
    },
    body: JSON.stringify(requestData)
}, function(error, response, body) {
    if (!error && response.statusCode == 200) {
    }
}); 
var MetaWeblog = require('metaweblog-api');
var apiUrl = 'http://localhost:3000/'; // use your blog API instead
var metaWeblog = new MetaWeblog(apiUrl);

// getUsersBlogs
metaWeblog.getUsersBlogs(appKey, username, password)
  .then(blogInfo => {
    // handle the blog information here
  });
  .catch(error => {
    console.log(error);
  });
  • deletePost(appKey, postid, username, password, publish) → {Promise.<(Boolean|Error)>}
  • editPost(postid, username, password, post, publish) → {Promise.<(Boolean|Error)>}
  • getCategories(blogid, username, password) → {Promise.<(Array.<CategoryInfo>|Error)>}
  • getPost(postid, username, password) → {Promise.<(Post|Error)>}
  • getRecentPosts(blogid, username, password, numberOfPosts) → {Promise.<(Array.<Post>|Error)>}
  • getUsersBlogs(appKey, username, password) → {Promise.<(Array.<BlogInfo>|Error)>}
  • newMediaObject(blogid, username, password, mediaObject) → {Promise.<(MediaObject|Error)>}
  • newPost(blogid, username, password, post, publish) → {Promise.<(Number|Error)>}
    • dateCreated Date + description + title,发布时必填
    • categories + permalink + link + postid + Source + userid + 其他字段,可选
    • Source = {name, url},UrlData = {url},
  • BlogInfo={blogid,url,blogName},Error={faultCode, faultString}
  • CategoryInfo={description,htmlUrl,rssUrl,title,categoryid}
  • MediaObject={name,type,bits base64}

tools/metaweblog.txt · 最后更改: 2019/01/05 17:57 由 admin