Gõ tên sản phẩm để tìm kiếm...
Phiên bản: 1.0
Ngôn ngữ: Tiếng Việt
Định dạng dữ liệu: JSON
Gửi khóa đại lý qua query string:
?api_key=YOUR_API_KEY
Ví dụ:
GET https://shoptuimu.site/api_sanpham.php?api_key=YOUR_API_KEY
GET /api_sanpham.php?api_key=YOUR_API_KEY Accept: application/json
| Tham số | Kiểu | Bắt buộc | Mô tả |
|---|---|---|---|
api_key |
string | Có | API key của tài khoản đại lý |
Endpoint hiện cho phép CORS từ mọi origin.
HTTP status hiện tại là 200:
{
"status": "success",
"ctv_name": "ten_dai_ly",
"main_products": [
{
"tier_name": "Túi Mù Game Mobile",
"icon": "fa-gamepad",
"products": [
{
"id": 55,
"name": "Skin Liên Quân VIP",
"price": 15000,
"stock": 12,
"tag": "HOT",
"image": "uploads/anh.png",
"description": "Mô tả sản phẩm",
"product_link": "chi-tiet-san-pham.php?id=55"
}
]
}
],
"event_products": [
{
"id": 1,
"name": "Tài Khoản Shopee",
"image": "uploads/shopee.png",
"description": "Mô tả sản phẩm sự kiện",
"price": 25000,
"tag": "EVENT",
"fake_sold": 3156
}
]
}
main_products: sản phẩm thường, được nhóm theo tier_name.event_products: sản phẩm sự kiện.price: giá bán dạng số, đơn vị Sao/đồng tùy cấu hình website chính. Web con không nên tự đổi định dạng hoặc cộng thêm giá nếu chưa có thỏa thuận riêng.stock: tồn kho hiện tại của sản phẩm thường.fake_sold: số lượt bán hiển thị, không phải tồn kho thật.image và product_link: có thể là đường dẫn tương đối. Khi cần dùng từ web con, nối với URL gốc của website chính.product_link là dữ liệu điều hướng, không được xem là API mua hàng.Thiếu API key:
{
"status": "error",
"message": "Từ chối truy cập! Thiếu API Key."
}
API key không hợp lệ:
{
"status": "error",
"message": "API Key không hợp lệ hoặc không tồn tại!"
}
Tài khoản bị khóa:
{
"status": "error",
"message": "Tài khoản Đại lý của bạn đã bị khóa! Liên hệ Trùm Tổng."
}
Chỉ gọi API sản phẩm từ trình duyệt nếu API key được phép công khai cho web con:
const API_BASE_URL = 'https://shoptuimu.site';
const API_KEY = 'YOUR_API_KEY';
async function loadProducts() {
const response = await fetch(
`${API_BASE_URL}/api_sanpham.php?api_key=${encodeURIComponent(API_KEY)}`,
{ headers: { Accept: 'application/json' } }
);
const data = await response.json();
if (!response.ok || data.status !== 'success') {
throw new Error(data.message || 'Không thể tải sản phẩm');
}
return data;
}
loadProducts()
.then(data => {
console.log('Đại lý:', data.ctv_name);
console.log('Sản phẩm thường:', data.main_products);
console.log('Sản phẩm sự kiện:', data.event_products);
})
.catch(console.error);
<?php
$baseUrl = 'https://shoptuimu.site';
$apiKey = getenv('WEB_CON_API_KEY');
$url = $baseUrl . '/api_sanpham.php?api_key=' . rawurlencode($apiKey);
$context = stream_context_create([
'http' => [
'method' => 'GET',
'header' => "Accept: application/json\r\n",
'timeout' => 10
]
]);
$json = file_get_contents($url, false, $context);
$data = json_decode($json, true);
if (!is_array($data) || ($data['status'] ?? '') !== 'success') {
throw new RuntimeException($data['message'] ?? 'API error');
}
$products = $data['main_products'];
Endpoint này dùng để thực hiện giao dịch mua túi mù trực tiếp từ Server của Web Con. Hệ thống sẽ tự động trừ số dư Đại lý (sau khi đã áp dụng chiết khấu VIP) và trả về tài khoản trúng thưởng dạng JSON.
POST /api_muahang.php
Content-Type: application/json
{
"api_key": "YOUR_API_KEY",
"product_name": "Tên sản phẩm chính xác như trong API danh sách"
}
{
"status": "success",
"message": "Giao dịch thành công!",
"data": {
"product_name": "Skin Liên Quân VIP",
"price_paid": 13500,
"balance_remaining": 1500000,
"account_details": [
"taikhoan1|matkhau1"
]
}
}
api_sanpham.php.main_products và event_products.product_link để chuyển đến trang chi tiết đã cấu hình.id nếu website chính chưa cung cấp endpoint mua hàng.