API="https://chungsucliqi.com/api/v1.php"
KEY="csk_xxxxxxxx"
# 1) Kiểm tra số dư
curl -s "$API?action=me" -H "X-API-Key: $KEY"
# 2) Đặt đơn
curl -s -X POST "$API?action=order" \
-H "X-API-Key: $KEY" -H "Content-Type: application/json" \
-d '{"product_id":1,"codes":["ABC123"],"client_ref":"don-0001"}'
# 3) Tra tiến độ (thay SS1113ABCDE bằng data.code ở bước 2)
curl -s "$API?action=order&code=SS1113ABCDE" -H "X-API-Key: $KEY"
<?php
const API = 'https://chungsucliqi.com/api/v1.php';
const KEY = 'csk_xxxxxxxx';
function call(string $method, string $action, array $query = [], ?array $body = null): array
{
$ch = curl_init(API . '?' . http_build_query(['action' => $action] + $query));
$head = ['X-API-Key: ' . KEY];
$opt = [CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30, CURLOPT_CUSTOMREQUEST => $method];
if ($body !== null) {
$head[] = 'Content-Type: application/json';
$opt[CURLOPT_POSTFIELDS] = json_encode($body);
}
$opt[CURLOPT_HTTPHEADER] = $head;
curl_setopt_array($ch, $opt);
$out = json_decode((string) curl_exec($ch), true);
curl_close($ch);
return is_array($out) ? $out : ['ok' => false, 'error' => ['code' => 'bad_response']];
}
// 1) Đặt đơn (client_ref giúp không bị trừ Xu hai lần khi gửi lại)
$res = call('POST', 'order', [], ['product_id' => 1, 'codes' => ['ABC123'], 'client_ref' => 'don-0001']);
if (!$res['ok']) exit('Lỗi: ' . $res['error']['code'] . ' - ' . ($res['error']['message'] ?? ''));
$code = $res['data']['code'];
echo "Đã tạo đơn $code, còn {$res['balance']} Xu\n";
// 2) Chờ đơn chạy xong
do {
sleep(20);
$info = call('GET', 'order', ['code' => $code])['data'];
echo $info['status'], PHP_EOL;
} while (!in_array($info['status'], ['done', 'cancelled'], true));
import time
import requests
API = 'https://chungsucliqi.com/api/v1.php'
HEAD = {'X-API-Key': 'csk_xxxxxxxx'}
def call(method, action, params=None, body=None):
q = {'action': action, **(params or {})}
return requests.request(method, API, params=q, json=body, headers=HEAD, timeout=30).json()
# 1) Đặt đơn (client_ref giúp không bị trừ Xu hai lần khi gửi lại)
res = call('POST', 'order', body={'product_id': 1, 'codes': ['ABC123'], 'client_ref': 'don-0001'})
if not res['ok']:
raise SystemExit(res['error'])
code = res['data']['code']
print('Đã tạo đơn', code, '- còn', res['balance'], 'Xu')
# 2) Chờ đơn chạy xong
while True:
info = call('GET', 'order', params={'code': code})['data']
print(info['status'], info.get('progress'))
if info['status'] in ('done', 'cancelled'):
break
time.sleep(20)
const API = 'https://chungsucliqi.com/api/v1.php';
const KEY = 'csk_xxxxxxxx';
async function call(method, action, { query = {}, body } = {}) {
const url = API + '?' + new URLSearchParams({ action, ...query });
const res = await fetch(url, {
method,
headers: { 'X-API-Key': KEY, ...(body ? { 'Content-Type': 'application/json' } : {}) },
body: body ? JSON.stringify(body) : undefined,
});
return res.json();
}
// 1) Đặt đơn (client_ref giúp không bị trừ Xu hai lần khi gửi lại)
const created = await call('POST', 'order', { body: { product_id: 1, codes: ['ABC123'], client_ref: 'don-0001' } });
if (!created.ok) throw new Error(created.error.code + ': ' + created.error.message);
const code = created.data.code;
console.log('Đã tạo đơn', code, '- còn', created.balance, 'Xu');
// 2) Chờ đơn chạy xong
let info;
do {
await new Promise((r) => setTimeout(r, 20000));
info = (await call('GET', 'order', { query: { code } })).data;
console.log(info.status, info.progress);
} while (!['done', 'cancelled'].includes(info.status));