voceconnect/thermal-api

一个JSON API,提供访问WordPress内部数据的功能

安装: 134

依赖项: 0

建议者: 0

安全性: 0

星级: 147

关注者: 22

分支: 16

开放问题: 18

类型:wordpress-plugin

0.13.4 2015-01-09 17:45 UTC

This package is not auto-updated.

Last update: 2024-09-14 14:40:01 UTC


README

请注意:此插件不再被积极维护或支持。

Thermal API

Build Status

当前API版本:v1

概述

Thermal是一个WordPress插件,允许您从WordPress管理界面外访问和控制内容。Thermal支持基于客户端的决策,当与响应式设计框架结合使用时,可以创建一个真正响应式的应用程序,利用WordPress内容源。

版本

为了支持迁移,API插件将支持最多2个版本的API。一旦某个版本超过1个周期,它将不再在API根目录中响应,除非配置为这样做。

API根目录

API的URL根目录将是API版本号,前面加上您的WordPress站点URL和Voce\Thermal\API_ROOT常量。默认设置为wp_api,但可以在wp-config.php中重写。

当前API版本是v1,因此默认URL根目录为

http://example.com/wp_api/v1/

资源类型

以下资源可用

文章

文章代表单个内容项。

方法

列表

请求
GET {api root}/posts
参数

响应
{
	'found': 40, //only provided if include_found == true
	"posts": [
		[Post Object],
		….
	]
}

单个实体

请求
GET {api root}/posts/{id}
参数
文章JSON模式
{
    "title": "Post Object",
    "description": "A representation of a single post object",
    "type": "object",
    "id": "#post",
    "properties": {
        "author": {
            "description": "The user set as the author of the post.",
            "type": {
                "$ref": "#user"
            },
            "required": true
        },
        "comment_count": {
            "description": "The number of comments for this post.",
            "type": "integer",
            "minimum": 0,
            "required": true
        },
        "comment_status": {
            "description": "The current status determining whether the post is accepting comments.",
            "enum": ["open", "closed"],
            "required": true
        },
        "content_display": {
            "description": "The content of the post after it has been run through the set 'the_content' filters.  Shortcodes are not expanded.",
            "type": "string",
            "required": true
        },
        "content": {
            "description": "The raw content of the post as it's stored in the database.",
            "type": "string",
            "required": true
        },
        "date": {
            "description": "The post's creation time in iso 8601 format.",
            "type": "string",
            "format": "date-time",
            "required": true
        },
        "excerpt_display": {
            "description": "The excerpt of the post after it has been run through the 'the_excerpt' filters.",
            "type": "string",
            "required": true
        },
        "excerpt": {
            "description": "The raw excerpt as it is stored in the database.",
            "type": "string",
            "required": true
        },
        "id_str": {
            "description": "The ID of the post represented as a string.",
            "type": "string",
            "required": true
        },
        "id": {
            "description": "The ID of the post",
            "type": "integer",
            "minimum": 1,
            "required": true
        },
        "type": {
            "description": "The post_type of the post",
            "type": "string",
            "required": true
        },
        "media": {
            "type": "array",
            "required": false,
            "items": {
                "type": {
                    "$ref": "#mediaItem"
                }
            }
        },
        "meta": {
            "description": "Additional data for the Post object.  Handling must be provided by other plugins to expand the provided meta beyond core properties.",
            "type": "object",
            "required": false,
            "default": {},
            "additionalProperties": {
                "featuredImage": {
                    "description": "The ID of the image being referenced as the featured image.  The referenced image should be present in the media property.",
                    "type": "integer",
                    "minimum": 1
                },
                "gallery": {
                	"description": "An array of objects that represent the galleries in the post content.",
                	"type": "array",
                	"required": false,
                	"items": {
                	 	"ids": {
                	 		"description": "The IDs of the attachments to be used in the gallery.",
                	 		"type": "array",
                	 		"required": false
                	 	},
                    	"orderby": {
                    		"description": "Specifies how to sort the display thumbnails.",
                    		"type": "array",
                    		"required": false
                    	},
                    	"order": {
                    		"description": "Specifies the sort order used to display thumbnails."
                    		"type": "string",
                    		"required": false
                    	},
                    	"in": {
                    		"description": "An array of IDs to only show the images from these attachments."
                    		"type": "array",
                    		"required": false
                    	},
                    	"exclude": {
                    		"description": "An array of IDs to not show the images from these attachments."
                    		"type": "array",
                    		"required": false
                    	},
                    	"id": {
                	 		"description": "The ID of the post to be used in the gallery. Used for specifying other posts.",
                	 		"type": "integer",
                	 		"required": false
                	 	}
                	}
                }
            }
        },
        "mime_type": {
            "description": "The mime type of the represented object",
            "type": "string",
            "required": true,
            "default": "text/html"
        },
        "modified": {
            "type": "string",
            "format": "date-time",
            "required": true
        },
        "name": {
            "description": "The name (slug) for the post, used in URLs.",
            "type": "string",
            "required": true
        },
        "parent_str": {
            "description": "The ID of the post's parent as a string, if it has one.",
            "type": "string",
            "required": false
        },
        "parent": {
            "description": "The ID of the post's parent as a string, if it has one.",
            "type": "integer",
            "required": false
        },
        "permalink": {
            "description": "The full permalink URL to the post.",
            "type": "string",
            "formate": "uri",
            "required": true
        },
        "status": {
            "description": "The status of the post.",
            "type": {
                "enum": ["publish", "draft", "pending", "future", "trash"]
            },
            "required": true
        },
        "taxonomies": {
            "description": "Key/Value pairs of taxonomies that exist for the given post where the Key is the name of the taxonomy.",
            "type": "object",
            "required": false,
            "default": {},
            "additionalProperties": {
                "category": {
                    "type": "array",
                    "items": {
                        "type": {
                            "$ref": "#term"
                        }
                    },
                    "required": false
                },
                "post_tag": {
                    "type": "array",
                    "items": {
                        "type": {
                            "$ref": "#term"
                        }
                    },
                    "required": false
                }
            }
        },
        "title": {
            "description": "The title of the Post.",
            "type": "string",
            "required": true
        }
    }
}
示例文章响应
{
	"id" : 1234567,
	"id_str" : "1234567",
	"type" : "post",
	"permalink": "http://example.com/posts/foobar/",
	"parent": 12345,
	"parent_str": "12345",
	"date": "2012-01-01T12:59:59+00:00",
	"modified": "2012-01-01T12:59:59+00:00",
	"status": "publish",
	"comment_status":"open",
	"comment_count": 99,
	"menu_order": 99,
	"title": "Lorem Ipsum Dolor!",
	"name": "loerm-ipsum-dolor"	,
	"excerpt": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sed lacus eros. Integer elementum urna.",
	"excerpt_display": "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sed lacus eros. Integer elementum urna.</p>",
	"content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nec consequatnibh. Quisque in consectetur ligula. Praesent pretium massa vitae neque adipiscing vita cursus nulla congue.\n<img src=\"http://example.com/wp-content/uploads/2012/03/foobar.jpg\" class=\"alignleft  size-medium wp-image-17115\" alt=\"Lorem ipsum doler set amut.\" />\n Cras aliquet ipsum non nisi accumsan tempor sollicitudin lacus interdum Donec in enim ut ligula dignissim tempor. Vivamus semper cursus mi, at molestie erat lobortiut. Pellentesque non mi vitae augue egestas vulputate et eu massa. Integer et sem orci. Suspendisse at augue in ipsum convallis semper.\n\n[gallery ids=\"1,2,3,4\"]\n\nNullam vitae libero eros, a fringilla erat. Suspendisse potenti. In dictum bibendum liberoquis facilisis risus malesuada ac. Nulla ullamcorper est ac lectus feugiat scelerisque.  Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas",
	"content_display": "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nec consequatnibh. Quisque in consectetur ligula. Praesent pretium massa vitae neque adipiscing vita cursus nulla congue.</p>\n<img src=\"http://example.com/wp-content/uploads/2012/03/foobar.jpg\" class=\"alignleft  size-medium wp-image-17115\" alt=\"Lorem ipsum doler set amut.\" />\n<p>Cras aliquet ipsum non nisi accumsan tempor sollicitudin lacus interdum Donec in enim ut ligula dignissim tempor. Vivamus semper cursus mi, at molestie erat lobortiut. Pellentesque non mi vitae augue egestas vulputate et eu massa. Integer et sem orci. Suspendisse at augue in ipsum convallis semper.</p>\n\n<div class=\"gallery\" id=\"gallery-1234\"></div>\n\n<p>Nullam vitae libero eros, a fringilla erat. Suspendisse potenti. In dictum bibendum liberoquis facilisis risus malesuada ac. Nulla ullamcorper est ac lectus feugiat scelerisque.  Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas</p>",
	"author": [User Object],
	"mime_type": "",
	"meta": {
		"featuredImage": 123456,
		"gallery" : [
			{
				"ids": [23],
				"orderby": [
					"menu_order",
					"ID"
				],
				"order": "ASC",
				….
			},
			….
		]
	},
	"taxonomies": {
		"category": [
			[Term Object],
			….
		],
		"post_tag": [
			[Term Object],
			….
		],
		….
	},
	"media": [
		{
			"type":
			"id": 123456,
			"id_str": ""123445",
			"altText": "Lorem ipsum doler set amut.",
			"mime_type": "image/jpg",
			"sizes": [
				{
					"name": "thumbnail",
					"width": 100,
					"height": 80,
					"url": "http://example.com/wp-content/uploads/2012/02/foobar-100x80.jpg"
				},
				….
			]
		},
		….
	]
}

##用户 用户代表网站上的单个作者或用户。

方法

列表

请求
GET {api root}/users
参数
响应
{
	'found': 40, //only provided if include_found == true
	"users": [
		[User Object],
		….
	]
}

单个实体

请求
GET {api root}/users/{id}
参数
用户JSON模式
{
    "description": "Representation of a single sytem user or author.",
    "id": "#user",
    "type": "object",
    "properties": {
        "id_str": {
            "description": "The ID of the User object as a string.",
            "type": "integer",
            "required": true
        },
        "id": {
            "description": "The ID of the User object.",
            "type": "integer",
            "required": true
        },
        "nicename": {
            "description": "The user's slug, or url safe name.",
            "type": "string",
            "required": false
        },
        "display_name": {
            "description": "The user's name as shown publicly.",
            "type": "string",
            "required": false
        },
        "posts_url": {
            "description": "The URL to the user's posts.",
            "type": "string",
            "format": "uri",
            "required": false
        },
        "user_url": {
            "description": "The User's personal URL.",
            "type": "string",
            "required": false
        },
        "avatar": {
            "description": "An array of images/sizes available for the User's avatar.",
            "type": "array",
            "items": {
                "description": "Image information for a User's Avatar.",
                "type": "object",
                "properties": {
                    "height": {
                        "description": "Height of the image in pixels.",
                        "type": "integer",
                        "required": true
                    },
                    "url": {
                        "description": "Full URL to the image resource.",
                        "type": "string",
                        "format": "uri",
                        "required": true
                    },
                    "width": {
                        "description": "Width of the image in pixels.",
                        "type": "integer",
                        "required": true
                    }
                }
            }
        },
        "meta": {
            "description": "Extended User data.",
            "type": "object"
        }
    }

}
示例用户响应
{
	"id" : 1234567,
	"id_str" : "1234567",
	"nicename": "john-doe",
	"display_name":"John Doe",
	"posts_url": "http://example.com/author/john-doe/",
	"user_url": "http://vocecomm.com",
	"avatar": [
		{
			"url":"http://1.gravatar.com/avatar/7a10459e7210f3bbaf2a75351255d9a3?s=64",
			"width":64,
			"height":64
		},
		….
	],
	"meta":{
		"nickname": "Johnny",
		"first_name": "John",
		"last_name": "Doe",
		"description": "Lorem ipsum dolar set amet."
	}
}

##分类法 分类法代表内容的不同分类类型。只有公共分类法可以通过API返回。

方法

列表

请求
GET {api root}/taxonomies
参数
响应
{
	"taxonomies": [
		[Taxonomy Object]
		….
	]
}

单个实体

请求
GET {api root}/taxonomies/{name}
参数
分类法JSON模式
{
    "id": "#taxonomy",
    "descrption": "A representation of a taxonomy.",
    "type": "object",
    "properties": {
        "name": {
            "description": "The name/unique identifier for the taxonomy.",
            "type": "string",
            "required": true
        },
        "post_type": {
            "description": "An array of post types the taxony is tied to.",
            "type": "array",
            "items": {
                "description": "The post_type string.",
                "type": "string"
            }
        },
        "hierarchical": {
            "description": "Indicates whether the taxonomy is hierarchical or allows parent/child relationships.",
            "type": "boolean",
            "default": false
        },
        "query_var": {
            "description": "The query_var tied to this taxonomy.  Useful when processing rewrite rules to determine the proper API query.",
            "type": "string",
            "required": false
        },
        "labels": {
            "description": "The user displayed name representing the taxonomy.",
            "type": "object",
            "properties": {
                "name": {
                    "description": "The plural name of the taxonomy.",
                    "type": "string"
                },
                "singularName": {
                    "description": "The singular name of the taxonomy.",
                    "type": "string"
                }
            }
        },
        "meta": {
            "description": "Extended Taxonomy data.",
            "type": "object"
        }
    }
}
示例分类法响应
{
	"name": "category",
	"post_types": [
		"post",
		"attachment",
		….
	],
	"hierarchical": true,
	"queryVar":"category",
	"labels": {
		"name": "Categories",
		"singularName": "Category"
	},
	"meta":{
	}
}

##术语 术语是分类法中的单个分类。

方法

列表

请求
GET {api root}/taxonomies/{name}/terms
参数
响应
{
	"found": 25,  //only provided if include_found == true
	"terms": [
		[Term Object]
		….
	]
}

单个实体

请求
GET {api root}/taxonomies/{name}/terms/{term_id}
参数

术语JSON模式

{
    "type": "object",
    "required": false,
    "properties": {
        "description": {
            "description": "A long text describing the term.",
            "type": "string",
            "required": false
        },
        "meta": {
            "description": "Extended Term data.",
            "type": "object",
        },
        "name": {
            "description": "The title/name of the term as displayed to users.",
            "type": "string",
            "required": false
        },
        "parent_str": {
            "description": "The ID of the parent term as a string, if exists.",
            "type": "string",
            "required": false
        },
        "parent": {
            "description": "The ID of the parent term, if exists.",
            "type": "number",
            "required": false
        },
        "post_count": {
            "description": "The distinct count of posts attached to this term.  If 'pad_count' is set to true, this will also include all posts attached to child terms.  This only includes posts of type 'post'.",
            "type": "number",
            "required": false
        },
        "slug": {
            "description": "The name (slug) of the term as used in URLs.",
            "type": "string",
            "required": false
        },
        "taxonomy": {
            "type": "string",
            "required": false
        },
        "id_str": {
            "description": "The ID of the term as a string.",
            "type": "string",
            "id": "http://jsonschema.net/term_id_str",
            "required": false
        },
        "id": {
            "description": "The ID of the term.",
            "type": "number",
            "id": "http://jsonschema.net/term_id",
            "required": false
        },
        "term_taxonomy_id_str": {
            "description": "The ID that uniquely represents this term/taxonomy as ing asterms are shared across multiple taxonomies.",
            "type": "string",
            "id": "http://jsonschema.net/term_taxonomy_id_str",
            "required": false
        },
        "term_taxonomy_id": {
            "description": "The ID that uniquely represents this term/taxonomy as terms are shared across multiple taxonomies.",
            "type": "number",
            "id": "http://jsonschema.net/term_taxonomy_id",
            "required": false
        }
    }
}
示例术语响应
{
	"id": 123456,
	"term_id_str": "123456",
	"term_taxonomy_id": 123456789,
	"term_taxonomy_id_str": "123456789",
	"parent": 1234567,
	"parent_str": "1234567",
	"name": "Local News",
	"slug": "local-news",
	"taxonomy": "category",
	"description": "News reports from around Polk County",
	"post_count": 25,
	"meta":{
	}
}

##重写规则 重写规则可以用于将内容中的内部链接转换为API请求。

方法

列表

请求
GET {api root}/rewrite_rules

重写规则JSON模式

{
    "id": "#rewrite_rules",
    "description": "Rewrite Rules represent the URL structure on the hosting API site.  Providing these to the client, allows the client to override internal links with sequential API requests.",
    "type": "object",
    "properties": {
        "base_url": {
            "description": "The root URL which all rewrite rules are based.",
            "type": "string",
            "format": "uri",
            "required": true
        },
        "rewrite_rules": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "query_expression": {
                        "description": "The format string used to build the resulting query parameters for the rewrite rules from the components matched from the regex.",
                        "type": "string",
                        "required": true
                    },
                    "regex": {
                        "description": "The regular expression used to break down the requested URL into components.",
                        "type": "string",
                        "format": "regex",
                        "required": true
                    }
                }
            }


        }
    }
}
示例重写规则响应
{
	"base_url": "http://example.com/",
	"rewrite_rules": [
		{
			"regex": "category/(.+?)/?$",
			"query_expression": "category_name=$1"
		}
		….
	]
}

媒体项目

以下是媒体项的模式。

基本媒体项JSON模式

{
    "description": "Base media object",
    "id": "mediaItem",
    "type": "object",
    "properties": {
        "type": {
            "description": "The subclass of media object being represented.",
            "type": "string",
            "required": true
        }
    }

}

内部媒体项基本JSON模式

{
    "description": "An internal media item hosted by this WP instance that is backed by a Post Object",
    "type": "object",
    "id": "#internalMediaItem",
    "extends": {
        "$ref": "#mediaItem"
    },
    "properties": {
        "idStr": {
            "description": "The ID of the Post object representing this media attachment as a string.",
            "type": "integer",
            "required": true
        },
        "id": {
            "description": "The ID of the Post object representing this media attachment.",
            "type": "integer",
            "required": true
        },
        "mimeType": {
            "description": "The mime type of the attched media object",
            "type": "string",
            "required": true
        },
    }
}

内部图像媒体项JSON模式

{
    "description": "An internal image item hosted by this WP instance",
    "type": "object",
    "id": "#internalMediaItem",
    "extends": {
        "$ref": "#mediaItem"
    },
    "properties": {
        "altText": {
            "description": "The alternate text for the image.  Maps to post_meta key '_wp_attachment_image_alt'.",
            "type": "string",
            "required": false
        },
        "sizes": {
            "description": "Listing of available sizes of the image allowing the proper size to be used for the client device.",
            "type": "array",
            "required": true,
            "items": {
                "type": "object",
                "required": true,
                "properties": {
                    "height": {
                        "description": "Height of the image in pixels.",
                        "type": "integer",
                        "required": true
                    },
                    "name": {
                        "description": "The identifier for the size that generated this size of the image.",
                        "type": "string",
                        "required": true
                    },
                    "url": {
                        "description": "Full URL to the image resource.",
                        "type": "string",
                        "format": "uri",
                        "required": true
                    },
                    "width": {
                        "description": "Width of the image in pixels.",
                        "type": "integer",
                        "required": true
                    }
                }
            }


        }
    }
}

评论

评论代表用户对文章的响应

方法

列表

请求
GET {api root}/comments

GET {api root}/posts/{#post_id}/comments
参数

响应
{
	'found': 40, //only provided if include_found == true
	"comments": [
		[Comment Object],
		….
	]
}

单个实体

请求
GET {api root}/comments/{id}
参数
评论JSON模式
{
    "title": "Comment Object",
    "description": "A representation of a single post object",
    "type": "object",
    "id": "#comment",
    "properties": {
        "author": {
            "description": "Display name of the author of the comment.",
            "type": "string",
            "required": true
        }
        "author_url": {
            "description": "URL set for the author of the comment.",
            "type": "string",
            "required": false
        }
        "date": {
            "description": "The comment's creation time in iso 8601 format.",
            "type": "string",
            "format": "date-time",
            "required": true
        },
        "content": {
            "description": "The raw comment content.",
            "type": "string",
            "required": true
        },
        "content_display": {
            "description": "Display formatted content of the comment.",
            "type": "string",
            "required": true
        },
        "user": {
            "description": "ID of the user making the comment",
            "type": "integer",
            "required": false
        },
					"user_id_str": {
            "description": "String version of the ID of the user making the comment",
            "type": "string",
            "required": false
        },
        "id_str": {
            "description": "The ID of the post represented as a string.",
            "type": "string",
            "required": true
        },
        "id": {
            "description": "The ID of the post",
            "type": "integer",
            "minimum": 1,
            "required": true
        },
        "type": {
            "description": "The type of comment.  Deafult enum: 'comment', 'pingback', 'trackback'",
            "type": "string",
            "required": true
        },
        "media": {
            "type": "array",
            "required": false,
            "items": {
                "type": {
                    "$ref": "#mediaItem"
                }
            }
        },
        "parent_str": {
            "description": "The ID of the comment's parent as a string, if it has one.",
            "type": "string",
            "required": false
        },
        "parent": {
            "description": "The ID of the comment's parent as a string, if it has one.",
            "type": "integer",
            "required": false
        },
        "status": {
            "description": "The status of the comment.",
            "type": {
                "enum": ["approve", "pending", "spam", "trash"]
            },
            "required": true
        }
    }
}
示例评论响应
{
    "id": 597,
    "id_str": "597",
    "type": "comment",
    "author": "John Doe",
    "author_url": "http://example.org",
    "parent": 0,
    "parent_str": "0",
    "date": "2013-06-11T18:39:46+00:00",
    "content": "This is my comment text",
    "status": "approve",
    "user": 1,
    "user_id_str": "1",
    "content_display": "<p>This is my comment text<\/p>\n",
    "avatar": [
        {
            "url": "http:\/\/1.gravatar.com\/avatar\/96614ec98aa0c0d2ee75796dced6df54?s=96&amp;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&amp;r=G",
            "width": 96,
            "height": 96
        }
    ]
}