All Projects → moefront → typecho-plugin-Restful

moefront / typecho-plugin-Restful

Licence: MIT License
Yet another awesome Typecho plugin to make your blog RESTful.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to typecho-plugin-Restful

PandaBangumi-Typecho-Plugin
给博客添加精美的追番展示页吧!
Stars: ✭ 65 (+58.54%)
Mutual labels:  typecho, typecho-plugin
typecho-api
基于Typecho的JSON API插件
Stars: ✭ 37 (-9.76%)
Mutual labels:  typecho, typecho-plugin
Typecho-Top-LamuLeimu
至顶至底(雷姆拉姆)Typecho插件
Stars: ✭ 27 (-34.15%)
Mutual labels:  typecho, typecho-plugin
JWPlayer
视频播放器插件 for Typecho 1.1
Stars: ✭ 42 (+2.44%)
Mutual labels:  typecho, typecho-plugin
DynamicLines-typecho-plugin
typecho插件,可以实现动态线条聚合特效
Stars: ✭ 48 (+17.07%)
Mutual labels:  typecho, typecho-plugin
cPlayer-Typecho-Plugin
A typecho plugin for a beautiful html5 music player https://github.com/MoePlayer/cPlayer/tree/f9b593dcd89395f9d7dd08ccda428f7628ab9ab2
Stars: ✭ 123 (+200%)
Mutual labels:  typecho, typecho-plugin
typecho-plugin-BlockIP
Typecho IP黑名单插件
Stars: ✭ 22 (-46.34%)
Mutual labels:  typecho, typecho-plugin
WeBlog
typecho微信小程序插件+微信小程序源码
Stars: ✭ 36 (-12.2%)
Mutual labels:  typecho, typecho-plugin
ArmX
typecho主题及插件ArmX
Stars: ✭ 46 (+12.2%)
Mutual labels:  typecho, typecho-plugin
DownloadFile
Typecho文件下载插件,使下载的文件保持上传时的文件名。
Stars: ✭ 12 (-70.73%)
Mutual labels:  typecho
ruo
Yet Another RESTful framework (**Work In Progress**)
Stars: ✭ 14 (-65.85%)
Mutual labels:  restful
rester
Fast and concise RESTful web framework based on fasthttp
Stars: ✭ 27 (-34.15%)
Mutual labels:  restful
rudder
RESTful API Proxy for Helm
Stars: ✭ 60 (+46.34%)
Mutual labels:  restful
lurch
A simple Ruby JSON API client.
Stars: ✭ 15 (-63.41%)
Mutual labels:  restful
yamlful
YAML-based HTTP client code generation
Stars: ✭ 77 (+87.8%)
Mutual labels:  restful
sdkgen
sdkgen is a tool to help design, implement and maintain good APIs with minimal effort
Stars: ✭ 61 (+48.78%)
Mutual labels:  restful
in-memoriam
Lightweight, super fast, atomic, transactional in-memory database
Stars: ✭ 13 (-68.29%)
Mutual labels:  restful
agile-wroking-backend
AgileWorking 是一个团队协作的微信小程序,此工程为小程序的后台实现
Stars: ✭ 67 (+63.41%)
Mutual labels:  restful
tuya-connector
tuya-connector helps you efficiently create cloud development projects regarding the OpenAPI or message subscription capabilities. You can put all the focus on business logic without taking care of server-side programming nor relational databases.
Stars: ✭ 28 (-31.71%)
Mutual labels:  restful
vue-php-admin
RBAC通用角色权限管理系统, 前后端分离架构, 基于 vue-element-admin 和 PHP CodeIgniter RESTful 实现
Stars: ✭ 4 (-90.24%)
Mutual labels:  restful

Typecho Restful 插件

Build Status Version styled with prettier built by

这是一个将 Typecho 博客 RESTful 化的插件。启用此插件,你可以通过请求 API 向站点请求或写入信息(获取文章内容、获取评论、添加评论等)。


食用方法

常规

下载插件并解压,将解压后的目录重命名为 Restful (区分大小写),然后到后台插件管理页面启用并设置即可。

使用 Composer 安装

cd /path/to/typecho/usr/plugins
composer create-project moefront/typecho-plugin-restful Restful --prefer-dist --stability=dev
chown www:www -R Restful

API

下面假设您的站点已经开启了地址重写(伪静态);如果没有的话,那么需要在下文列出的请求的 URI 前加上 /index.php,例如:/api/posts => /index.php/api/posts.

文章列表

GET /api/posts

参数 类型 描述
page int 当前页 可选
pageSize int 分页数 可选
filterType string category 或 tag 或 search 可选
filterSlug string 分类名或标签名或搜索关键字 可选
showContent bool 是否显示文章具体内容 可选
showDigest string 指定是否显示文章摘要及显示摘要的类型 可选
limit int 当 showDigest 的类型为 excerpt 时,指定截断的字数 可选

PS: showDigest 有两个可选的值,分别为 moreexcerpt. 当选用 more 模式时,插件将返回文章中 <!--more--> 标签前的内容解析后的 HTML;选用 excerpt 模式时,插件将对解析后的文章过滤 HTML 标签后,返回前 limit 个字符。默认 limit 的值为 200.

页面列表

GET /api/pages

分类列表

GET /api/categories

标签列表

GET /api/tags

文章/页面详情

GET /api/post

参数 类型 描述
cid int 文章/页面 ID 二选一
slug string 文章/页面别名 二选一

评论列表

GET /api/comments

参数 类型 描述
page int 当前页 可选
pageSize int 分页数 可选
order string 评论显示顺序(asc/desc) 可选
cid int 文章 ID 二选一
slug string 文章别名 二选一

PS: 如果带上 Cookie 请求,会显示当前 Cookie 记住的用户所发布的待审核的评论。

最近评论

GET /api/recentComments

参数 类型 描述
size int 最近评论的条数,默认为 9 可选

发表评论

POST /api/comment

参数 类型 描述
cid int 文章 ID 二选一
slug string 文章别名 二选一
parent int 父级评论 ID 可选
text string 评论内容 必须
author string 作者 必须
mail string 邮箱 必须
url string URL 可选
token string 文章/页面详情返回的 token 必须
uid int 已注册用户评论时,用户的 UID 可选
authCode string 已注册用户评论时,用户的 authCode 可选

PS:此处Content-Typeapplication/json, 也就是说你应当以 JSON 格式提交数据。

PS2: uid 和 authCode 可以在 Cookie 中找到(形如 hash__typecho_uidhash__typecho_authCode 的内容)。如果直接带上 Cookie 请求此 API 则不再需要带上 uidauthCode 参数。请求时需要带上合法的 User-Agent.

设置项

GET /api/settings

用户信息

GET /api/users

参数 类型 描述
uid int 用户 ID 可选
name string 用户的用户名或昵称 可选

归档

GET /api/archives

PS:默认按从新到旧 (desc) 顺序排列文章。

参数 类型 描述
order string 归档的排序方式 (asc / desc) 可选
showContent bool 是否显示文章内容 可选
showDigest string 指定是否显示文章摘要及显示摘要的类型 可选
limit int 当 showDigest 的类型为 excerpt 时,指定截断的字数 可选

PS: showDigestlimit 参数的使用参见 /api/posts 部分。

其它

自定义 URI 前缀

默认情况下 Restful 插件会占用 /api/* 用于不同的接口。如果该 URI 有其它用途,或与其它插件冲突,或者由于某些不可描述的原因用户不希望暴露该接口,可以选择通过修改 config.inc.php 自定义前缀。

例如,在 config.inc.php 文件中加入下列内容:

define('__TYPECHO_RESTFUL_PREFIX__', '/rest/');

重新启用插件,此时你可以通过 /rest/* 访问相关 API.

License

typecho-plugin-restful is MIT licensed.

Since it is a derivative of Typecho which is GPLv2 licensed, you may also need to observe GPLv2 when you are redistributing this plugin.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].