edit doc
Change-Id: I2ec270156f26b4a1887c6549b74a6a83f51fa222
This commit is contained in:
parent
5b8e9ef5d8
commit
e80ee742e8
@ -96,7 +96,7 @@ getAuthors()方法返回的是用户相关的信息:
|
|||||||
PostRequest post = new PostRequest();
|
PostRequest post = new PostRequest();
|
||||||
post.setPostTitle("测试Title");
|
post.setPostTitle("测试Title");
|
||||||
post.setPostContent("这是一段测试文章内容");
|
post.setPostContent("这是一段测试文章内容");
|
||||||
post.setCategories("测试");
|
post.setCategories("分类1","分类2");
|
||||||
post.setTags("a", "b", "c");
|
post.setTags("a", "b", "c");
|
||||||
post.setPostName("test-post-name");
|
post.setPostName("test-post-name");
|
||||||
int postId = wp.newPost(post);
|
int postId = wp.newPost(post);
|
||||||
@ -105,6 +105,10 @@ getAuthors()方法返回的是用户相关的信息:
|
|||||||
|
|
||||||
这里需要注意postName和postTitle。postTitle指的是文章标题;postName指的则是文章别名,主要在文章的url路径中使用。通常建议将postName设置为英文字符。
|
这里需要注意postName和postTitle。postTitle指的是文章标题;postName指的则是文章别名,主要在文章的url路径中使用。通常建议将postName设置为英文字符。
|
||||||
|
|
||||||
|
setCategories设置的是文章分类,要求设置的分类在博客中必须已经存在,且名称需要一致。
|
||||||
|
|
||||||
|
setTags设置的是文章标签,不要求在博客中已经存在。
|
||||||
|
|
||||||
更多发布文章的参数可以参考[XML-RPC WordPress API/Posts - newPost](https://codex.wordpress.org/XML-RPC_WordPress_API/Posts#wp.newPost)文档描述。
|
更多发布文章的参数可以参考[XML-RPC WordPress API/Posts - newPost](https://codex.wordpress.org/XML-RPC_WordPress_API/Posts#wp.newPost)文档描述。
|
||||||
|
|
||||||
## 获取文章
|
## 获取文章
|
||||||
|
2
pom.xml
2
pom.xml
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
<groupId>org.chobit.wp</groupId>
|
<groupId>org.chobit.wp</groupId>
|
||||||
<artifactId>wordpress-client</artifactId>
|
<artifactId>wordpress-client</artifactId>
|
||||||
<version>0.1.1</version>
|
<version>0.1.2</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>WordPress-Client</name>
|
<name>WordPress-Client</name>
|
||||||
|
@ -1,9 +1,17 @@
|
|||||||
package org.chobit.wp.enums;
|
package org.chobit.wp.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author robin
|
||||||
|
*/
|
||||||
public enum PostTaxonomy {
|
public enum PostTaxonomy {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文章分类
|
||||||
|
*/
|
||||||
CATEGORY("category"),
|
CATEGORY("category"),
|
||||||
|
/**
|
||||||
|
* 文章标签
|
||||||
|
*/
|
||||||
TAG("post_tag"),
|
TAG("post_tag"),
|
||||||
;
|
;
|
||||||
public final String taxonomy;
|
public final String taxonomy;
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
package org.chobit.wp.model.interval;
|
package org.chobit.wp.model.interval;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author robin
|
||||||
|
*/
|
||||||
public class Enclosure {
|
public class Enclosure {
|
||||||
|
|
||||||
private String url;
|
private String url;
|
||||||
|
@ -3,6 +3,9 @@ package org.chobit.wp.model.request;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author robin
|
||||||
|
*/
|
||||||
public class PostFilter extends Request {
|
public class PostFilter extends Request {
|
||||||
|
|
||||||
@JsonProperty("post_type")
|
@JsonProperty("post_type")
|
||||||
|
@ -13,6 +13,9 @@ import java.util.Map;
|
|||||||
import static org.chobit.wp.enums.PostTaxonomy.CATEGORY;
|
import static org.chobit.wp.enums.PostTaxonomy.CATEGORY;
|
||||||
import static org.chobit.wp.enums.PostTaxonomy.TAG;
|
import static org.chobit.wp.enums.PostTaxonomy.TAG;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author robin
|
||||||
|
*/
|
||||||
public class PostRequest extends Request {
|
public class PostRequest extends Request {
|
||||||
|
|
||||||
public PostRequest() {
|
public PostRequest() {
|
||||||
|
@ -9,6 +9,9 @@ import java.util.Map;
|
|||||||
import static org.chobit.wp.tools.JsonKit.fromJson;
|
import static org.chobit.wp.tools.JsonKit.fromJson;
|
||||||
import static org.chobit.wp.tools.JsonKit.toJson;
|
import static org.chobit.wp.tools.JsonKit.toJson;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author robin
|
||||||
|
*/
|
||||||
public abstract class Request {
|
public abstract class Request {
|
||||||
|
|
||||||
public Map<String, Object> toMap() throws IOException {
|
public Map<String, Object> toMap() throws IOException {
|
||||||
|
@ -3,6 +3,9 @@ package org.chobit.wp.model.response;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author robin
|
||||||
|
*/
|
||||||
public class Author {
|
public class Author {
|
||||||
|
|
||||||
@JsonProperty("user_id")
|
@JsonProperty("user_id")
|
||||||
|
@ -5,6 +5,9 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author robin
|
||||||
|
*/
|
||||||
public class MediaItem {
|
public class MediaItem {
|
||||||
|
|
||||||
@JsonProperty("attachment_id")
|
@JsonProperty("attachment_id")
|
||||||
|
@ -6,6 +6,9 @@ import org.chobit.wp.model.interval.Enclosure;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author robin
|
||||||
|
*/
|
||||||
public class Post {
|
public class Post {
|
||||||
|
|
||||||
@JsonProperty("post_id")
|
@JsonProperty("post_id")
|
||||||
|
@ -3,6 +3,9 @@ package org.chobit.wp.model.response;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author robin
|
||||||
|
*/
|
||||||
public class Term {
|
public class Term {
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user