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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值