wordpress标题摘要等更多参数的发送
做wordpress XML-RPC开发的时候到处寻找接口说明,可是网上只能找到标题、关键字、正文信息的发送,更多的参数就很难找到了,而且官网的接口说明文档更是滥,太简陋了,但是我又必须要用那些参数,所以只好把wordpress提供的接口php文件拿出来仔细研究,虽然对php不怎么熟悉,但是大概的意识还是能才出来的,哈哈。通过分析wordpress中class-wp-xmlrpc-server.php文件,总结了更多常用的发送选项,贴出来供大家分享:
/** * @param args * @throws XmlRpcException * @throws MalformedURLException * @throws ParseException */public static void main(String[] args) throws XmlRpcException, MalformedURLException, ParseException {// TODO Auto-generated method stub//String url = "http://127.0.0.1/wordpress/xmlrpc.php";//设置链接到远程接口的对象 XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); config.setServerURL(new URL(url)); XmlRpcClient client = new XmlRpcClient(); client.setConfig(config); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //设置参数 Map post = new HashMap(); post.put("title", "这是标题");// 标题 post.put("wp_slug", "this is slug"); post.put("mt_excerpt", "这是摘要信息");//摘要 post.put("mt_keywords", new String []{"l1","l2"});// 标签 post.put("categories", new String []{"测试文章","子分类","java"}); //分类 post.put("description", "这是正文");// 内容 post.put("mt_text_more", "this is text more"); post.put("mt_allow_comments", "open");//open/closed 是否允许评论 post.put("mt_allow_pings", "closed");//open/closed 文章是否接受 trackback 和 pingback。 post.put("mt_tb_ping_urls", new String[]{"http://t.sino.com","http://192.168.0.1:8080/wordpress"});//Trackback 是针对老式博客系统的一种引用通知方式。 post.put("dateCreated", sdf.parse("2011-5-10 16:17:20"));// post.put("date_created_gmt", sdf.parse("2011-5-10 14:00:00"));//和上面的属性意义差不多 Object[] params = new Object[] { "1", "ros", "ros", post, Boolean.TRUE}; //true-文章 false-草稿 String rt = (String) client.execute("metaWeblog.newPost", params); System.out.println("Created with blogid " + rt); }以下是其中提供的其他一些参数,有时间原因没有明确意思:
post_type
wp_page_template
wp_post_format
wp_slug别名
wp_password
wp_page_parent_id
wp_page_order
wp_author_id
title
description
mt_excerpt 摘要
mt_keywords 关键字
mt_text_more 扩展文字#post_more "<!--more-->"
mt_allow_comments
mt_allow_pings
mt_tb_ping_urls
date_created_gmt
dateCreated
categories
sticky
custom_fields
enclosure 需要属性:url length type