TUNGKAO ឯកសារ API
ចុចប៊ូតុង ហើយជ្រើស “Save as PDF”

TUNGKAO API

ចូលតាម Reddit

API v1 · ធ្វើបច្ចុប្បន្នភាពចុងក្រោយ: ម៉ោងប្រទេសថៃ (UTC+07:00)

https://tungkao.com · https://api.tungkao.com/docs

ត្រូវបង្ហាញ “Powered by TUNGKAO” ភ្ជាប់ទៅ https://tungkao.com នៅលើទំព័រដែលប្រើសេវា

API · reddit_login

ចូលតាម Reddit

បន្ថែមប៊ូតុង 'ចូលតាម Reddit' ក្នុងគេហទំព័រដោយមិនចាំបាច់ចុះឈ្មោះជាមួយ Reddit ខ្លួនឯង ទទួលបាន៖ username, avatar (no email)

🕒 ធ្វើបច្ចុប្បន្នភាពចុងក្រោយ: ម៉ោងប្រទេសថៃ (UTC+07:00) · ✅ កូដចាស់នៅដំណើរការ មិនចាំបាច់កែ

🤖 ឱ្យ AI សរសេរកូដភ្ជាប់

ចម្លងតំណនេះឱ្យ AI អាន ឬចុចប៊ូតុង ប្រព័ន្ធនឹងចម្លងពាក្យបញ្ជា ហើយបើក AI

https://api.tungkao.com/docs/api/reddit_login.md?lang=km
https://api.tungkao.com/changelog/reddit_login.json

តំណនេះផ្ដល់បច្ចុប្បន្នភាពរបស់ API នេះជា JSON (មិនត្រូវការ key បើកពីគ្រប់ដែន)។ បង្ហាញក្នុងទំព័រគ្រប់គ្រងជាប្រអប់ “ប្រកាសបច្ចុប្បន្នភាព” ហើយដាក់ “ថ្មី” ពេល last_updated ប្ដូរ

ChatGPT ↗Claude ↗Gemini ↗Grok ↗

ចម្លង + បើកក្នុង: ចុចប៊ូតុង AI ប្រព័ន្ធនឹងចម្លងពាក្យបញ្ជា បើប្រអប់ជជែកទទេ គ្រាន់តែបិទភ្ជាប់

🔑 key ដែលត្រូវប្រើ

បង្កើត key reddit_login នៅផតថលអាជីវករ (API key) ហើយផ្ញើ header នេះគ្រប់សំណើ — key សេវាផ្សេងមិនដំណើរការនៅទីនេះ

Authorization: Bearer $TUNGKAO_KEY

🔗 តំណប៊ូតុងចូលរបស់អ្នក

https://api.tungkao.com/oauth/authorize?client_id=<CLIENT_ID>&redirect_uri=https%3A%2F%2Fyourshop.com%2Fauth%2Fcallback&state=<RANDOM>

🛡️ គ្រប់ជំហានបញ្ចប់នៅ tungkao៖ អ្នកប្រើចូលជាមួយ Reddit ហើយត្រឡប់មក tungkao មុនជានិច្ច យើងបញ្ជូនទៅតំណរបស់អ្នកតែពេលចូលជោគជ័យពិត (ឬបោះបង់ពេលចូល) — អ្នកបើកតំណផ្ទាល់ឃើញតែទំព័រ tungkao កំណត់ 🌐 domain (ផ្ទៀងផ្ទាត់) និង ↩️ តំណត្រឡប់ នៅ 'សមាជិក'

អ្នកទទួលបាន: username, avatar (no email)

📋 ជំហាន

  1. បង្កើត key សម្រាប់អ្នកផ្ដល់សេវា ហើយនៅ 'សមាជិកចូល' កំណត់ឈ្មោះគេហទំព័រ និង redirect URI (https ដូចទាំងស្រុង)
  2. ប៊ូតុងចូលនាំអ្នកប្រើទៅ /oauth/authorize ជាមួយ client_id (លេខ key), redirect_uri និង state (ចៃដន្យថ្មី រក្សាក្នុង session)
  3. អ្នកប្រើត្រឡប់មក redirect_uri?code=…&state=… → ពិនិត្យ state → ម៉ាស៊ីនមេហៅ POST /v1/login/token ក្នុង 2 នាទី
  4. ប្រើ data.user (ឧ. 7F3K9QX2-yourshopcom) ជាលេខសមាជិក — មនុស្សដដែលទទួលលេខដដែលជានិច្ច

📡 ការហៅ API + គំរូកូដ

POST/v1/login/token
curl -X POST https://api.tungkao.com/v1/login/token \
  -H "Authorization: Bearer $TUNGKAO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"code":"from the redirect","redirect_uri":"https://yourshop.com/auth/callback"}'
GET/v1/login/users?limit=50
curl -X GET https://api.tungkao.com/v1/login/users?limit=50 \
  -H "Authorization: Bearer $TUNGKAO_KEY"

📖 Summary: using sign-in keys on several sites

ករណីការកំណត់ key (ទំព័រ API Keys)លទ្ធផល
One site, 2 keys of the same provider (e.g. website + app, both Google)Both keys: Combined (default)The same person gets the same user ID in both ✅
One site, 2 keys of the same provider, counted as separate accountsBoth keys: SeparateThe same person gets a different user ID on each key
2 sister sites sharing membersBoth keys: Group AA member has the same user ID on both sites ✅
2 unrelated sites that must not link membersBoth keys: SeparateDifferent user IDs, so the sites can't link their members ✅
A Google key and a LINE key (different providers)Any settingAlways different user IDs — they are different provider accounts
A key that already has sign-ins needs a different groupNot allowed (locked 🔒)Create a new key in the wanted group, so member IDs on your site never change

Set it on the “Sign-in user IDs between keys” card on the API Keys page before go-live (new keys default: Combined). Several keys may use the same domain.

គំរូពេញ (ប៊ូតុង + callback + ប្ដូរ code)

// npm i express express-session
import express from "express";
import session from "express-session";
import crypto from "node:crypto";

const KEY = process.env.TUNGKAO_KEY;            // API key (tk_live_…) server-side only
const CLIENT_ID = process.env.TUNGKAO_CLIENT_ID; // the key id (shown in the portal), not a secret
const REDIRECT = "https://yourshop.com/auth/callback"; // must match the registered URL exactly

const app = express();
app.use(session({ secret: process.env.SESSION_SECRET, resave: false, saveUninitialized: false, cookie: { secure: true, sameSite: "lax" } }));

// 1) your "Sign in" button links here
app.get("/auth/login", (req, res) => {
  req.session.state = crypto.randomBytes(24).toString("base64url");
  const u = new URL("https://api.tungkao.com/oauth/authorize");
  u.search = new URLSearchParams({ client_id: CLIENT_ID, redirect_uri: REDIRECT, state: req.session.state });
  res.redirect(u);
});

// 2) the user comes back with a code
app.get("/auth/callback", async (req, res) => {
  if (!req.query.state || req.query.state !== req.session.state) return res.status(400).send("state mismatch");
  delete req.session.state;
  if (req.query.error) return res.redirect("/login?cancelled=1");
  // 3) exchange the code for the user (within 2 minutes)
  const r = await fetch("https://api.tungkao.com/v1/login/token", {
    method: "POST",
    headers: { Authorization: `Bearer ${KEY}`, "Content-Type": "application/json" },
    body: JSON.stringify({ code: req.query.code, redirect_uri: REDIRECT }),
  });
  const j = await r.json();
  if (!j.success) return res.status(400).send(j.error.message);
  req.session.user = j.data; // j.data.user = permanent member id, e.g. 7F3K9QX2-yourshopcom
  res.redirect("/");
});
app.listen(3000);
អ្នកផ្ដល់សេវាសេវាអ្នកទទួលបាន
Googlegoogle_loginឈ្មោះ អ៊ីមែលផ្ទៀងផ្ទាត់ រូប
LINEline_loginឈ្មោះ រូប អ៊ីមែលបើយល់ព្រម
Facebookfacebook_loginឈ្មោះ រូប អ៊ីមែល
TikToktiktok_loginឈ្មោះបង្ហាញ រូប (គ្មានអ៊ីមែល)
Discorddiscord_loginឈ្មោះ រូប អ៊ីមែល
Telegramtelegram_loginname, username, photo
X (Twitter)x_loginname, username, photo
Microsoftmicrosoft_loginname, email (Hotmail/Outlook)
GitHubgithub_loginname, email, avatar
Appleapple_loginpermanent member ID (no name or email in this mode)
Steamsteam_loginname, avatar and SteamID (no email)
Twitchtwitch_loginname, email, avatar
LinkedInlinkedin_loginname, email, photo
Kakaokakao_loginname, photo (email once Kakao approves it)
NAVERnaver_loginname, email, photo
Zalozalo_loginname, photo (no email)
Spotifyspotify_loginname, email, photo
Redditreddit_loginusername, avatar (no email)
GitLabgitlab_loginname, email, avatar
Robloxroblox_loginname, avatar (no email)
Epic Gamesepicgames_logindisplay name (no email)
Yahooyahoo_loginname, email, photo
Slackslack_loginname, email, photo
Amazonamazon_loginname, email

📚 ឧទាហរណ៍ការប្រើ

ឧទាហរណ៍ 1

A “Sign in with Reddit” button on your site

ស្ថានការណ៍: A visitor taps Sign in with Reddit on your site

សំណើ
GET /oauth/authorize?client_id=<CLIENT_ID>&redirect_uri=https://yourshop.com/auth/callback&state=xyz

➡️ The user signs in with Reddit and returns to redirect_uri with a code and the same state

ឧទាហរណ៍ 2

Exchange the code for the user (server side)

ស្ថានការណ៍: Your server receives the code on the callback page (exchange within 2 minutes)

សំណើ
POST /v1/login/token
{
  "code": "<code from the callback>",
  "redirect_uri": "https://yourshop.com/auth/callback"
}
ឧទាហរណ៍ចម្លើយ
{
  "success": true,
  "data": {
    "user": "7F3K9QX2-yourshopcom",
    "provider": "reddit",
    "name": "Somchai",
    "is_new_user": true
  }
}

➡️ Use user as the member id in your database (stable per person)

ឧទាហរណ៍ 3

A returning user signs in

ស្ថានការណ៍: The same person signs in with Reddit again

ឧទាហរណ៍ចម្លើយ
{
  "success": true,
  "data": {
    "user": "7F3K9QX2-yourshopcom",
    "is_new_user": false,
    "login_count": 5
  }
}

➡️ Same user every time → look up the member and sign them in

ឧទាហរណ៍ 4

One site, two Reddit keys (website + app)

ស្ថានការណ៍: Separate keys for website and app, same members

➡️ Keep both keys “Combined” (default) before go-live → same user for the same person. Choose “Separate” to keep them apart

ឧទាហរណ៍ 5

List members who signed in

ស្ថានការណ៍: You want to browse or search members of this key

សំណើ
GET /v1/login/users?q=somchai&limit=50

➡️ Returns members with last sign-in time and count

ឧទាហរណ៍ 6

The user cancels during sign-in

ស្ថានការណ៍: The user cancels on the Reddit screen

➡️ Returns to redirect_uri with error instead of code; show a retry button

💡 បន្ថែម

📜 ប្រវត្តិបច្ចុប្បន្នភាព API នេះ

  1. បន្ថែម ម៉ោងប្រទេសថៃ (UTC+07:00)
    🖼️ Show your own logo on the sign-in page, per key (50×50, auto-cropped and resized). Billed monthly: buy 1–11 months or 1 / 2 / 3 years. Hiding the credit now offers the same periods.
  2. កែលម្អ ម៉ោងប្រទេសថៃ (UTC+07:00)
    🌐 The sign-in page and the phone-model sign-in help now support all 10 API languages (th, en, lo, my, zh-CN, ko, ja, vi, km, id), picked from the device language or &lang= on the sign-in link, with a language switcher at the bottom
  3. កែលម្អ ម៉ោងប្រទេសថៃ (UTC+07:00)
    📱 The sign-in help page now names the visitor's exact phone model (e.g. Galaxy S24 Ultra), adds model search, and refreshes the Android model list daily from Google Play — new models get a “New” badge
  4. បន្ថែម ម៉ោងប្រទេសថៃ (UTC+07:00)
    📱 Step-by-step “sign-in doesn't continue” help by phone brand and model (iPhone, iPad, Samsung, Huawei, HONOR, Xiaomi, OPPO, vivo, realme, OnePlus, Pixel, other Android), with the brand guessed from the device and a link from the sign-in page
  5. បន្ថែម ម៉ោងប្រទេសថៃ (UTC+07:00)
    Sign-in: choose whether user IDs are combined or separate between keys (whole account / group A–E / separate). New keys default to combined; keys that already have sign-ins stay in their group
  6. បន្ថែម ម៉ោងប្រទេសថៃ (UTC+07:00)
    15 new sign-in providers: Apple, Steam, Twitch, LinkedIn, Kakao, NAVER, Zalo, Spotify, Reddit, GitLab, Roblox, Epic Games, Yahoo, Slack, Amazon. Same /oauth/authorize link and POST /v1/login/token as every existing provider (each one goes on sale when ready; see the services page)
  7. បន្ថែម ម៉ោងប្រទេសថៃ (UTC+07:00)
    API update announcements by webhook: new api.update event (opt in per key on the key card; off by default)
  8. បន្ថែម ម៉ោងប្រទេសថៃ (UTC+07:00)
    error.user_message: ready-to-show text for end users on outages, no credits or key problems (white-label keys omit tungkao.com)
  9. បន្ថែម ម៉ោងប្រទេសថៃ (UTC+07:00)
    GET /status៖ ស្ថានភាព API តាមសេវា (មិនត្រូវការ key)
  10. បន្ថែម ម៉ោងប្រទេសថៃ (UTC+07:00)
    កុងតាក់បើក/បិទ key និងម៉ោងប្ដូរ + គេហទំព័រ 1 key 1 សម្រាប់សេវានីមួយៗ
  11. កែលម្អ ម៉ោងប្រទេសថៃ (UTC+07:00)
    ចាក់សោ API v1 ជាអចិន្ត្រៃយ៍ (បន្ថែមតែប៉ុណ្ណោះ) + header X-Tungkao-Api-Version + ជូនដំណឹងមុន 12 ខែ
  12. ឯកសារ ម៉ោងប្រទេសថៃ (UTC+07:00)
    ទំព័រឯកសារតាម API និងតំណ AI (10 ភាសា)
  13. សុវត្ថិភាព ម៉ោងប្រទេសថៃ (UTC+07:00)
    ផ្ទៀងផ្ទាត់ domain តាម API key (key 1 = គេហទំព័រ 1) — key ចាស់នៅដំណើរការ
  14. បន្ថែម ម៉ោងប្រទេសថៃ (UTC+07:00)
    ចុះហត្ថលេខា HMAC ជាជម្រើស — មិនបើកក៏ដូចដើម
  15. បន្ថែម ម៉ោងប្រទេសថៃ (UTC+07:00)
    រយៈពេល API key ការជូនដំណឹង និងការបន្ត — key ដដែល
  16. បន្ថែម ម៉ោងប្រទេសថៃ (UTC+07:00)
    key របៀប test (សាកល្បង ឥតគិតថ្លៃ) គ្រប់សេវា

✅ កូដចាស់នៅដំណើរការ មិនចាំបាច់កែ

🛡️ ការសន្យាស្ថិរភាព៖ ភ្ជាប់ម្ដង ប្រើបានជានិច្ច

🚦 ស្ថានភាពប្រព័ន្ធ (GET /status)

ពិនិត្យថា API ធម្មតាឬទេ គ្រប់ពេល — មិនត្រូវការ key

GET https://api.tungkao.com/status

curl https://api.tungkao.com/status
{
  "success": true,
  "data": {
    "status": "ok",
    "services": [
      { "id": "slip_verify", "status": "ok", "routes": ["ok", "ok", "busy"] },
      { "id": "slip_deposit", "status": "ok", "routes": ["ok", "ok", "busy"] },
      { "id": "login", "status": "ok" },
      { "id": "telegram", "status": "ok" },
      { "id": "discord", "status": "ok" },
      { "id": "email", "status": "busy" },
      { "id": "crypto", "status": "ok" },
      { "id": "core", "status": "ok" }
    ],
    "paused": [],
    "updated_at": "2026-11-14T12:00:00.000Z"
  }
}

🏷️ លក្ខខណ្ឌដាក់ក្រេឌីត TUNGKAO

Powered by TUNGKAO