minute to read


BUAT HALAMAN BARU

Buat halaman baru.

Semua permintaan ke API memerlukan API Token. Anda dapat menemukan token di pengaturan plugin API.

Admin panel > Plugins > API > API Token

Untuk semua permintaan ke API untuk menulis konten, Anda harus menyediakan Authentication Token. Untuk mendapatkan token ini, Anda memerlukan pengguna dengan peran Administrator. Dapatkan Authentication Token dari profil pengguna.

Admin panel > Manage > Users > {Username} > Security > Authentication Token

HTTP Request

POST /api/pages/{key}

Parameters

key value Default value
required token string API Token.
required authentication string Authentication token.
title string Page title.
content string Page content.
tags string Page tags, separated by comma.
type string Page type.
date string Page date (formatted as "YYYY-MM-DD Hours:Minutes:Seconds").
slug string Page URL slug. (Derived from lowercased title)
dateModified string Page modified date.
position string Page position.
coverImage string Page cover image.
category string Page category.
template string Page template.
noindex string Page noindex.
nofollow string Page nofollow.
noarchive string Page noarchive.

Response

HTTP Code: 200
Content-Type: application/json
Body:
{
    "status": "0",
    "message": "Page created.",
    "data": {
        "key": "<page key>"
    }
}

CURL command example

Berikut adalah contoh yang menunjukkan cara membuat halaman baru melalui baris perintah dengan perintah curl. File data.json memiliki data dasar yang diperlukan untuk membuat halaman baru.

Isi file data.json:

{
    "token": "24a8857ed78a8c89a91c99afd503afa7",
    "authentication": "193569a9d341624e967486efb3d36d75",
    "title": "My dog",
    "content": "Content of the page here, support Markdown code and HTML code."
}

Jalankan perintah dan lampirkan file data.json:

$ curl  -X POST \
    -H "Content-Type: application/json" \
    -d @data.json \
    "https://www.example.com/api/pages"

Response Body

{
    "status": "0",
    "message": "Page created.",
    "data": {
        "key": "my-dog"
    }
}