Accounts
Facebook Accounts RESTful API v2
API RESTful để quản lý tài khoản Facebook với đầy đủ các chức năng CRUD, tìm kiếm và thống kê.
Base URL
https://kkdemo.kkwebsite.com/api/v2/fb-accountsAuthentication
API sử dụng JWT token authentication. Token phải được gửi trong header:
Authorization: Bearer {your_jwt_token}1. Lấy Danh Sách Tài Khoản
Mô tả
Lấy danh sách tất cả tài khoản Facebook với phân trang và filter.
Endpoint, Method, Authentication
GET https://kkdemo.kkwebsite.com/api/v2/fb-accountsAuthentication: Bearer token
Authorization: Bearer YOUR_TOKEN_HERETham số (query)
| Tên | Kiểu | Bắt buộc | Mô tả |
|---|---|---|---|
| page | Integer | Không | Số trang (mặc định: 1) |
| limit | Integer | Không | Số lượng mỗi trang (max 100, mặc định: 10) |
| u_active | Integer | Không | Trạng thái hoạt động (0/1) |
| u_status | String | Không | Trạng thái tài khoản |
| fb_level | Integer | Không | Level tài khoản (0-4) |
| fb_type | String | Không | Loại tài khoản (add/new/sales/seeding) |
| cat_id | Integer | Không | ID danh mục |
| u_live | Integer | Không | Trạng thái live (0/1) |
| f_block | Integer | Không | Trạng thái block (0/1) |
| search | String | Không | Từ khóa tìm kiếm |
| search_field | String | Không | Trường tìm kiếm (all/u_name/u_mail/u_uid, mặc định: all) |
Code Example
curl -X GET "https://kkdemo.kkwebsite.com/api/v2/fb-accounts?page=1&limit=10" \
-H "Authorization: Bearer YOUR_TOKEN_HERE" \
-H "Content-Type: application/json"Cấu hình HTTP Request Node:
- URL:
https://kkdemo.kkwebsite.com/api/v2/fb-accounts - Method:
GET - Query Parameters:
page: 1 limit: 10 u_status: live fb_level: 2 - Headers:
Authorization: Bearer YOUR_TOKEN_HERE Content-Type: application/json
function getFacebookAccounts($page = 1, $limit = 10, $filters = []) {
$url = 'https://kkdemo.kkwebsite.com/api/v2/fb-accounts';
$params = [
'page' => $page,
'limit' => $limit
];
// Thêm các filter
if (isset($filters['u_status'])) $params['u_status'] = $filters['u_status'];
if (isset($filters['fb_level'])) $params['fb_level'] = $filters['fb_level'];
if (isset($filters['search'])) $params['search'] = $filters['search'];
$url .= '?' . http_build_query($params);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer YOUR_TOKEN_HERE',
'Content-Type: application/json'
]);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
// Sử dụng
$accounts = getFacebookAccounts(1, 10, ['u_status' => 'live', 'fb_level' => 2]);import requests
import json
def get_facebook_accounts(page=1, limit=10, filters=None):
url = 'https://kkdemo.kkwebsite.com/api/v2/fb-accounts'
params = {
'page': page,
'limit': limit
}
if filters:
params.update(filters)
headers = {
'Authorization': 'Bearer YOUR_TOKEN_HERE',
'Content-Type': 'application/json'
}
response = requests.get(url, headers=headers, params=params)
return response.json()
# Sử dụng
accounts = get_facebook_accounts(page=1, limit=10, filters={'u_status': 'live', 'fb_level': 2})Response
{
"status": "success",
"data": [
{
"u_id": 1,
"u_name": "user1",
"u_uid": 123456789,
"u_mail": "user1@example.com",
"u_pass": "password123",
"u_active": 1,
"u_status": "live",
"fb_level": 2,
"fb_type": "sales",
"category_name": "Category 1",
"created_at": "2024-01-01 00:00:00",
"updated_at": "2024-01-01 00:00:00"
}
],
"pagination": {
"page": 1,
"limit": 10,
"total": 100,
"total_pages": 10
}
}{
"status": "error",
"message": "Unauthorized",
"code": 401
}2. Lấy Thông Tin Chi Tiết Tài Khoản
Mô tả
Lấy thông tin chi tiết của một tài khoản Facebook theo ID.
Endpoint, Method, Authentication
GET https://kkdemo.kkwebsite.com/api/v2/fb-accounts/{id}Authentication: Bearer token
Authorization: Bearer YOUR_TOKEN_HERECode Example
curl -X GET "https://kkdemo.kkwebsite.com/api/v2/fb-accounts/1" \
-H "Authorization: Bearer YOUR_TOKEN_HERE" \
-H "Content-Type: application/json"Cấu hình HTTP Request Node:
- URL:
https://kkdemo.kkwebsite.com/api/v2/fb-accounts/1 - Method:
GET - Headers:
Authorization: Bearer YOUR_TOKEN_HERE Content-Type: application/json
function getFacebookAccount($id) {
$url = 'https://kkdemo.kkwebsite.com/api/v2/fb-accounts/' . $id;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer YOUR_TOKEN_HERE',
'Content-Type: application/json'
]);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
// Sử dụng
$account = getFacebookAccount(1);import requests
def get_facebook_account(account_id):
url = f'https://kkdemo.kkwebsite.com/api/v2/fb-accounts/{account_id}'
headers = {
'Authorization': 'Bearer YOUR_TOKEN_HERE',
'Content-Type': 'application/json'
}
response = requests.get(url, headers=headers)
return response.json()
# Sử dụng
account = get_facebook_account(1)Response
{
"status": "success",
"data": {
"u_id": 1,
"u_name": "user1",
"u_uid": 123456789,
"u_mail": "user1@example.com",
"u_pass": "password123",
"u_active": 1,
"u_status": "live",
"fb_level": 2,
"fb_type": "sales",
"security": {
"u_2fa": "2fa_code",
"mail_pass": "mail_password"
},
"social": {
"u_gender": "male",
"u_birthday": "1990-01-01",
"u_phone": "0123456789"
},
"activity": {
"u_status_last": "active",
"login_gpm": 1
},
"groups": [
{
"gr_id": 1,
"gr_name": "Group 1",
"gr_url": "group1",
"joined": 1,
"can_post": 1,
"type": 1
}
],
"assistants": [
{
"id": 1,
"title": "Assistant 1"
}
]
}
}{
"status": "error",
"message": "Không tìm thấy tài khoản với ID: 999",
"code": 404
}3. Tìm Kiếm Tài Khoản
Mô tả
Tìm kiếm tài khoản Facebook theo ID, UID hoặc email.
Endpoint, Method, Authentication
GET https://kkdemo.kkwebsite.com/api/v2/fb-accounts/searchAuthentication: Bearer token
Authorization: Bearer YOUR_TOKEN_HERETham số (query)
| Tên | Kiểu | Bắt buộc | Mô tả |
|---|---|---|---|
| type | String | Có | Loại tìm kiếm (u_id/u_uid/u_mail) |
| value | String | Có | Giá trị tìm kiếm |
Code Example
curl -X GET "https://kkdemo.kkwebsite.com/api/v2/fb-accounts/search?type=u_mail&value=user1@example.com" \
-H "Authorization: Bearer YOUR_TOKEN_HERE" \
-H "Content-Type: application/json"Cấu hình HTTP Request Node:
- URL:
https://kkdemo.kkwebsite.com/api/v2/fb-accounts/search - Method:
GET - Query Parameters:
type: u_mail value: user1@example.com - Headers:
Authorization: Bearer YOUR_TOKEN_HERE Content-Type: application/json
function searchFacebookAccount($type, $value) {
$url = 'https://kkdemo.kkwebsite.com/api/v2/fb-accounts/search';
$params = [
'type' => $type,
'value' => $value
];
$url .= '?' . http_build_query($params);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer YOUR_TOKEN_HERE',
'Content-Type: application/json'
]);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
// Sử dụng
$result = searchFacebookAccount('u_mail', 'user1@example.com');import requests
def search_facebook_account(search_type, value):
url = 'https://kkdemo.kkwebsite.com/api/v2/fb-accounts/search'
params = {
'type': search_type,
'value': value
}
headers = {
'Authorization': 'Bearer YOUR_TOKEN_HERE',
'Content-Type': 'application/json'
}
response = requests.get(url, headers=headers, params=params)
return response.json()
# Sử dụng
result = search_facebook_account('u_mail', 'user1@example.com')Response
{
"status": "success",
"data": {
"u_id": 1,
"u_name": "user1",
"u_uid": 123456789,
"u_mail": "user1@example.com"
}
}{
"status": "error",
"message": "Không tìm thấy tài khoản",
"code": 404
}4. Tạo Tài Khoản Mới
Mô tả
Tạo tài khoản Facebook mới trong hệ thống.
Endpoint, Method, Authentication
POST https://kkdemo.kkwebsite.com/api/v2/fb-accountsAuthentication: Bearer token
Authorization: Bearer YOUR_TOKEN_HERETham số (body JSON)
| Tên | Kiểu | Bắt buộc | Mô tả |
|---|---|---|---|
| u_name | String | Không | Tên tài khoản |
| u_mail | String | Có | Email tài khoản (tối đa 100 ký tự) |
| u_pass | String | Có | Mật khẩu (tối đa 30 ký tự) |
| u_uid | Integer | Không | UID Facebook |
| cat_id | Integer | Không | ID danh mục |
| fb_level | Integer | Không | Level tài khoản (0-4) |
| fb_type | String | Không | Loại tài khoản (add/new/sales/seeding) |
| security | Object | Không | Thông tin bảo mật |
| social | Object | Không | Thông tin xã hội |
Code Example
curl -X POST "https://kkdemo.kkwebsite.com/api/v2/fb-accounts" \
-H "Authorization: Bearer YOUR_TOKEN_HERE" \
-H "Content-Type: application/json" \
-d '{
"u_name": "newuser",
"u_mail": "newuser@example.com",
"u_pass": "password123",
"u_uid": 987654321,
"cat_id": 1,
"fb_level": 1,
"fb_type": "new",
"security": {
"u_2fa": "2fa_code",
"mail_pass": "mail_password"
},
"social": {
"u_gender": "female",
"u_birthday": "1995-01-01"
}
}'Cấu hình HTTP Request Node:
- URL:
https://kkdemo.kkwebsite.com/api/v2/fb-accounts - Method:
POST - Send Body:
true - Body Type:
JSON - Headers:
Authorization: Bearer YOUR_TOKEN_HERE Content-Type: application/json - Body (JSON):
{ "u_name": "newuser", "u_mail": "newuser@example.com", "u_pass": "password123", "u_uid": 987654321, "fb_level": 1, "fb_type": "new" }
function createFacebookAccount($data) {
$url = 'https://kkdemo.kkwebsite.com/api/v2/fb-accounts';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer YOUR_TOKEN_HERE',
'Content-Type: application/json'
]);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
// Sử dụng
$accountData = [
'u_name' => 'newuser',
'u_mail' => 'newuser@example.com',
'u_pass' => 'password123',
'u_uid' => 987654321,
'fb_level' => 1,
'fb_type' => 'new'
];
$result = createFacebookAccount($accountData);import requests
import json
def create_facebook_account(data):
url = 'https://kkdemo.kkwebsite.com/api/v2/fb-accounts'
headers = {
'Authorization': 'Bearer YOUR_TOKEN_HERE',
'Content-Type': 'application/json'
}
response = requests.post(url, headers=headers, data=json.dumps(data))
return response.json()
# Sử dụng
account_data = {
'u_name': 'newuser',
'u_mail': 'newuser@example.com',
'u_pass': 'password123',
'u_uid': 987654321,
'fb_level': 1,
'fb_type': 'new'
}
result = create_facebook_account(account_data)Response
{
"status": "success",
"message": "Tạo tài khoản thành công",
"data": {
"u_id": 2,
"u_name": "newuser",
"u_mail": "newuser@example.com",
"created_at": "2024-01-01 00:00:00"
}
}{
"status": "error",
"message": "Lỗi validation: Email đã tồn tại",
"code": 400
}5. Cập Nhật Tài Khoản
Mô tả
Cập nhật thông tin tài khoản Facebook theo ID.
Endpoint, Method, Authentication
PUT https://kkdemo.kkwebsite.com/api/v2/fb-accounts/{id}Authentication: Bearer token
Authorization: Bearer YOUR_TOKEN_HERETham số (body JSON)
| Tên | Kiểu | Bắt buộc | Mô tả |
|---|---|---|---|
| u_name | String | Không | Tên tài khoản |
| u_status | String | Không | Trạng thái tài khoản |
| fb_level | Integer | Không | Level tài khoản (0-4) |
| security | Object | Không | Thông tin bảo mật |
Code Example
curl -X PUT "https://kkdemo.kkwebsite.com/api/v2/fb-accounts/1" \
-H "Authorization: Bearer YOUR_TOKEN_HERE" \
-H "Content-Type: application/json" \
-d '{
"u_name": "updateduser",
"u_status": "live",
"fb_level": 3,
"security": {
"u_2fa": "new_2fa_code"
}
}'Cấu hình HTTP Request Node:
- URL:
https://kkdemo.kkwebsite.com/api/v2/fb-accounts/1 - Method:
PUT - Send Body:
true - Body Type:
JSON - Headers:
Authorization: Bearer YOUR_TOKEN_HERE Content-Type: application/json - Body (JSON):
{ "u_name": "updateduser", "u_status": "live", "fb_level": 3 }
function updateFacebookAccount($id, $data) {
$url = 'https://kkdemo.kkwebsite.com/api/v2/fb-accounts/' . $id;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer YOUR_TOKEN_HERE',
'Content-Type: application/json'
]);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
// Sử dụng
$updateData = [
'u_name' => 'updateduser',
'u_status' => 'live',
'fb_level' => 3
];
$result = updateFacebookAccount(1, $updateData);import requests
import json
def update_facebook_account(account_id, data):
url = f'https://kkdemo.kkwebsite.com/api/v2/fb-accounts/{account_id}'
headers = {
'Authorization': 'Bearer YOUR_TOKEN_HERE',
'Content-Type': 'application/json'
}
response = requests.put(url, headers=headers, data=json.dumps(data))
return response.json()
# Sử dụng
update_data = {
'u_name': 'updateduser',
'u_status': 'live',
'fb_level': 3
}
result = update_facebook_account(1, update_data)Response
{
"status": "success",
"message": "Cập nhật tài khoản thành công",
"data": {
"u_id": 1,
"u_name": "updateduser",
"u_status": "live",
"fb_level": 3,
"updated_at": "2024-01-01 00:00:00"
}
}{
"status": "error",
"message": "Không tìm thấy tài khoản",
"code": 404
}6. Xóa Tài Khoản
Mô tả
Xóa tài khoản Facebook theo ID.
Endpoint, Method, Authentication
DELETE https://kkdemo.kkwebsite.com/api/v2/fb-accounts/{id}Authentication: Bearer token
Authorization: Bearer YOUR_TOKEN_HERECode Example
curl -X DELETE "https://kkdemo.kkwebsite.com/api/v2/fb-accounts/1" \
-H "Authorization: Bearer YOUR_TOKEN_HERE" \
-H "Content-Type: application/json"Cấu hình HTTP Request Node:
- URL:
https://kkdemo.kkwebsite.com/api/v2/fb-accounts/1 - Method:
DELETE - Headers:
Authorization: Bearer YOUR_TOKEN_HERE Content-Type: application/json
function deleteFacebookAccount($id) {
$url = 'https://kkdemo.kkwebsite.com/api/v2/fb-accounts/' . $id;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer YOUR_TOKEN_HERE',
'Content-Type: application/json'
]);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
// Sử dụng
$result = deleteFacebookAccount(1);import requests
def delete_facebook_account(account_id):
url = f'https://kkdemo.kkwebsite.com/api/v2/fb-accounts/{account_id}'
headers = {
'Authorization': 'Bearer YOUR_TOKEN_HERE',
'Content-Type': 'application/json'
}
response = requests.delete(url, headers=headers)
return response.json()
# Sử dụng
result = delete_facebook_account(1)Response
{
"status": "success",
"message": "Xóa tài khoản thành công"
}{
"status": "error",
"message": "Không tìm thấy tài khoản",
"code": 404
}7. Cập Nhật Trạng Thái Tài Khoản
Mô tả
Cập nhật trạng thái của tài khoản Facebook.
Endpoint, Method, Authentication
PATCH https://kkdemo.kkwebsite.com/api/v2/fb-accounts/{id}/statusAuthentication: Bearer token
Authorization: Bearer YOUR_TOKEN_HERETham số (body JSON)
| Tên | Kiểu | Bắt buộc | Mô tả |
|---|---|---|---|
| u_status | String | Có | Trạng thái mới (live/die/new) |
Code Example
curl -X PATCH "https://kkdemo.kkwebsite.com/api/v2/fb-accounts/1/status" \
-H "Authorization: Bearer YOUR_TOKEN_HERE" \
-H "Content-Type: application/json" \
-d '{
"u_status": "die"
}'Cấu hình HTTP Request Node:
- URL:
https://kkdemo.kkwebsite.com/api/v2/fb-accounts/1/status - Method:
PATCH - Send Body:
true - Body Type:
JSON - Headers:
Authorization: Bearer YOUR_TOKEN_HERE Content-Type: application/json - Body (JSON):
{ "u_status": "die" }
function updateAccountStatus($id, $status) {
$url = 'https://kkdemo.kkwebsite.com/api/v2/fb-accounts/' . $id . '/status';
$data = ['u_status' => $status];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer YOUR_TOKEN_HERE',
'Content-Type: application/json'
]);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
// Sử dụng
$result = updateAccountStatus(1, 'die');import requests
import json
def update_account_status(account_id, status):
url = f'https://kkdemo.kkwebsite.com/api/v2/fb-accounts/{account_id}/status'
headers = {
'Authorization': 'Bearer YOUR_TOKEN_HERE',
'Content-Type': 'application/json'
}
data = {'u_status': status}
response = requests.patch(url, headers=headers, data=json.dumps(data))
return response.json()
# Sử dụng
result = update_account_status(1, 'die')Response
{
"status": "success",
"message": "Cập nhật trạng thái thành công",
"data": {
"u_id": 1,
"old_status": "live",
"new_status": "die"
}
}{
"status": "error",
"message": "Trạng thái không hợp lệ",
"code": 400
}8. Lấy Thống Kê Tài Khoản
Mô tả
Lấy thống kê tổng quan về tài khoản Facebook.
Endpoint, Method, Authentication
GET https://kkdemo.kkwebsite.com/api/v2/fb-accounts/statsAuthentication: Bearer token
Authorization: Bearer YOUR_TOKEN_HERECode Example
curl -X GET "https://kkdemo.kkwebsite.com/api/v2/fb-accounts/stats" \
-H "Authorization: Bearer YOUR_TOKEN_HERE" \
-H "Content-Type: application/json"Cấu hình HTTP Request Node:
- URL:
https://kkdemo.kkwebsite.com/api/v2/fb-accounts/stats - Method:
GET - Headers:
Authorization: Bearer YOUR_TOKEN_HERE Content-Type: application/json
function getAccountStats() {
$url = 'https://kkdemo.kkwebsite.com/api/v2/fb-accounts/stats';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPGET, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer YOUR_TOKEN_HERE',
'Content-Type: application/json'
]);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
// Sử dụng
$stats = getAccountStats();import requests
def get_account_stats():
url = 'https://kkdemo.kkwebsite.com/api/v2/fb-accounts/stats'
headers = {
'Authorization': 'Bearer YOUR_TOKEN_HERE',
'Content-Type': 'application/json'
}
response = requests.get(url, headers=headers)
return response.json()
# Sử dụng
stats = get_account_stats()Response
{
"status": "success",
"data": {
"total": 1000,
"by_status": {
"live": 800,
"die": 150,
"new": 50
},
"by_level": {
"0": 200,
"1": 300,
"2": 250,
"3": 150,
"4": 100
},
"by_type": {
"add": 400,
"new": 300,
"sales": 200,
"seeding": 100
},
"by_active": {
"1": 900,
"0": 100
}
}
}{
"status": "error",
"message": "Unauthorized",
"code": 401
}Status Codes
| Code | Mô tả |
|---|---|
| 200 | Thành công |
| 201 | Tạo thành công |
| 400 | Lỗi validation |
| 401 | Unauthorized |
| 404 | Không tìm thấy |
| 500 | Lỗi server |
Rate Limiting
API có giới hạn rate limiting để tránh spam:
- 100 requests/phút cho mỗi token
- 1000 requests/giờ cho mỗi token
Logging
Tất cả các thao tác sửa đổi (CREATE, UPDATE, DELETE, STATUS_CHANGE) sẽ được ghi log với prefix "API" trong message để phân biệt với các thao tác từ giao diện web.
Validation Rules
Required Fields (khi tạo mới)
u_mail: Email (tối đa 100 ký tự)u_pass: Mật khẩu (tối đa 30 ký tự)
Optional Fields
u_uid: UID Facebook (số)cat_id: ID danh mụcfb_level: Level tài khoản (0-4)fb_type: Loại tài khoản (add/new/sales/seeding)u_language: Ngôn ngữ (mặc định: EN)security: Thông tin bảo mậtsocial: Thông tin xã hộiactivity: Thông tin hoạt động
