Semua endpoint membutuhkan token Bearer di header Authorization.
Endpoint: /register.php
Method: POST
Request Body:
{
"username": "your_username",
"email": "your_email",
"password": "your_password"
}Response:
{
"message": "Registrasi berhasil"
}Endpoint: /login.php
Method: POST
Request Body:
{
"email": "your_email",
"password": "your_password"
}Response:
{
"message": "Login berhasil",
"token": "your_token",
"user": {
"id": "user_id",
"username": "your_username",
"email": "your_email"
}
}Endpoint: /tasks.php
Method: POST
Request Body:
{
"idtask": "task_id",
"categoryname": "category_name",
"membername": "member_name",
"taskname": "task_name",
"frequency": "everyday",
"period": 1,
"selectdate": "YYYY-MM-DD",
"time": "HH:MM:SS"
}Response:
{
"message": "Task created"
}Endpoint: /tasks.php
Method: GET
Response:
[
{
"idtask": "task_id",
"userid": "user_id",
"categoryname": "category_name",
"membername": "member_name",
"taskname": "task_name",
"frequency": "everyday",
"period": 1,
"selectdate": "YYYY-MM-DD",
"time": "HH:MM:SS"
},
...
]Endpoint: /tasks.php
Method: PUT
Request Body:
{
"idtask": "task_id",
"categoryname": "category_name",
"membername": "member_name",
"taskname": "task_name",
"frequency": "everyday",
"period": 1,
"selectdate": "YYYY-MM-DD",
"time": "HH:MM:SS"
}Response:
{
"message": "Task updated"
}Endpoint: /tasks.php
Method: DELETE
Query Parameter: idtask
Response:
{
"message": "Task deleted"
}Endpoint: /tasks.php?action=forgot_password
Method: POST
Request Body:
{
"email": "your_email",
"username": "your_username",
"new_password": "your_new_password"
}Response:
{
"message": "Password updated successfully"
}Berikut adalah langkah-langkah untuk menguji API menggunakan Postman:
- Buka Postman dan buat permintaan baru.
- Atur metode permintaan (misalnya, POST, GET, PUT, DELETE).
- Masukkan URL endpoint (misalnya,
http://localhost/schedular_app/api/register.php). - Untuk endpoint yang membutuhkan autentikasi, tambahkan token Bearer di header Authorization:
Authorization: Bearer your_token - Untuk endpoint yang membutuhkan body permintaan, buka tab Body, pilih
raw, dan atur tipe keJSON. Masukkan payload JSON sesuai dokumentasi. - Klik
Senduntuk menjalankan permintaan dan melihat respons.
| Kolom | Tipe | Konstraint |
|---|---|---|
| idtask | INT(11) | PRIMARY KEY, AUTO_INCREMENT |
| userid | INT(11) | FOREIGN KEY(users.id) |
| categoryname | VARCHAR(50) | NULLABLE |
| membername | VARCHAR(50) | NULLABLE |
| taskname | VARCHAR(50) | NULLABLE |
| frequency | ENUM('everyday','everyweek','everymonth','everyyear') | NULLABLE |
| period | INT(11) | NULLABLE |
| selectdate | DATE | NULLABLE |
| time | TIME | NULLABLE |
| Kolom | Tipe | Konstraint |
|---|---|---|
| id | INT(11) | PRIMARY KEY, AUTO_INCREMENT |
| username | VARCHAR(50) | UNIQUE, NOT NULL |
| VARCHAR(50) | UNIQUE, NOT NULL | |
| password | VARCHAR(255) | NOT NULL |
| token | VARCHAR(255) | NULLABLE |
Untuk menangani autentikasi JWT, instal paket berikut:
composer require firebase/php-jwt