Skip to content

Latest commit

 

History

History
280 lines (230 loc) · 5.58 KB

File metadata and controls

280 lines (230 loc) · 5.58 KB

Cavern API Reference

Table of Content

Login

User

Constants

Role

The role of a user represent the permission given to the user.

A user's role is usually sent as a number in the response. However, we suggest using displayed name when it is shown to user.

Level Displayed Name View post Comment Like Receive notification Create new posts Edit posts Delete posts
0 會員
1 作者 him/herself him/herself
8 管理員 all all
9 站長 all all

Types

User

Contains information about a user.

Json representation
{
    "username": string,
    "name": string,
    "level": number,
    "role": string,
    "hash": string,
    "muted": boolean,
    "posts_count": number,
    "login": boolean,
    "fetch": number
}
Fields
username The user's username.
name The user's displayed name.
level The user's role. See Role's section.
role The displayed name of the user's role. It will always be compatible with the level number.
hash Hashed value of the user's email. Call
https://www.gravatar.com/avatar/{hash}?d=https%3A%2F%2Ftocas-ui.com%2Fassets%2Fimg%2F5e5e3a6.png&s=500
to get user's avatar.
muted Indicate whether the user can create new post, edit post, and comment.
posts_count The number of posts which was created by the user.
login Indicate whether the request sender is logged in.
fetch Fetch series of the request.

CurrentUser

Contains information about the current user, which has logged in on the client side.

This is a extended version of User which contains more information.

Json representation
{
    "username": string,
    "name": string,
    "level": number,
    "role": string,
    "hash": string,
    "muted": boolean,
    "posts_count": number,
    "email": string,
    "login": boolean,
    "fetch": number
}
Fields
username The current user's username.
name The current user's displayed name.
level The current user's role. See Role's section.
role The displayed name of the current user's role. It will always be compatible with the level number.
hash Hashed value of the current user's email. Call
https://www.gravatar.com/avatar/{hash}?d=https%3A%2F%2Ftocas-ui.com%2Fassets%2Fimg%2F5e5e3a6.png&s=500
to get user's avatar.
muted Indicate whether the current user can create new post, edit post, and comment.
posts_count The number of posts which was created by the current user.
email The email of the current user.
login It should always be true. Since there's no current user if there's no user logged in on the client side.
fetch Fetch series of the request.

Errors

NoUserError

Get when the specific username you queried is not available.

Json Representation
{
    "status":"nouser",
    "login": boolean,
    "fetch": number
}
Fields
status The error message. In this case, it is always "nouser".
login Indicate whether the request sender is logged in.
fetch Fetch series of the request.

Methods

get

HTTP request

GET /ajax/user.php

Response body

Developer can call this method if and only if the client is logged in. The server will return a CurrentUser.

However, if the client isn't logged in, the server will send out a 404 error.

get_with_username

HTTP requeset

GET /ajax/user.php?username={username}

Paramaters
username string
The username of the user who you want to query.

Response body

If the request sender is logged in, and the username of the current user is the same as the queried username, the server will return a CurrentUser. Otherwise, a User will be returned.

Post

Constants

Like

Comment

Notification