TUNGKAO API 文档
点击按钮后选择“另存为 PDF”

TUNGKAO API

用 Zalo 登录

API v1 · 最近更新: 泰国时间(UTC+07:00)

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

根据服务条款,使用本服务的页面必须显示指向 https://tungkao.com 的 “Powered by TUNGKAO”(登录/支付可用 “Secured by TUNGKAO”)

API · zalo_login

用 Zalo 登录

无需自己注册 Zalo,即可在网站加上“用 Zalo 登录”按钮。获得:name, photo (no email)

🕒 最近更新: 泰国时间(UTC+07:00) · ✅ 现有代码照常可用,无需修改

🤖 让 AI 帮你写对接代码

复制此链接给 AI 阅读(该 API 的完整 Markdown),或点击下方按钮:自动复制提示词并打开所选 AI,粘贴后告诉它你的语言/框架

https://api.tungkao.com/docs/api/zalo_login.md?lang=zh-CN
https://api.tungkao.com/changelog/zalo_login.json

此链接以 JSON 返回该 API 的更新(无需 key,任何域名可访问)。可在后台显示为“更新公告”框,last_updated 变化时标记“新”

复制并打开: 点击 AI 按钮会自动复制提示词,若对话框为空直接粘贴即可

🔑 使用的密钥

在商户后台(API key)创建 zalo_login 密钥,并在每个请求中发送此 header——其他服务的密钥在这里无效

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 完成:用户用 Zalo 登录后总是先回到 tungkao。只有真正登录成功(或登录中取消)才会转到你的链接——直接打开链接的人只会看到 tungkao 页面。在“会员”页设置 🌐 域名(需验证)和 ↩️ 返回链接。

获得: name, photo (no email)

📋 步骤

  1. 为该平台创建密钥,然后在“登录会员”设置网站名称和返回地址(https,完全一致)。
  2. 你的登录按钮把用户带到 /oauth/authorize,附带 client_id(密钥 ID)、redirect_uri 和 state(每次新的随机值,保存在 session)。
  3. 用户返回 redirect_uri?code=…&state=… → 校验 state → 你的服务器在 2 分钟内调用 POST /v1/login/token。
  4. 用 data.user(如 7F3K9QX2-yourshopcom)作为会员 ID——同一个人永远得到同一个 ID。

📡 接口调用 + 代码示例

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.

完整示例(按钮 + 回调 + 兑换 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 Zalo” button on your site

场景: A visitor taps Sign in with Zalo on your site

请求
GET /oauth/authorize?client_id=<CLIENT_ID>&redirect_uri=https://yourshop.com/auth/callback&state=xyz

➡️ The user signs in with Zalo 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": "zalo",
    "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 Zalo 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 Zalo 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 Zalo 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 状态(无需密钥)
  10. 新增 泰国时间(UTC+07:00)
    密钥开关及状态变更时间 + 每个网站每项服务 1 个密钥
  11. 改进 泰国时间(UTC+07:00)
    API v1 永久冻结(仅新增)+ X-Tungkao-Api-Version header + 提前 12 个月的弃用通知
  12. 文档 泰国时间(UTC+07:00)
    每个 API 独立文档页及 AI 链接(10 种语言)
  13. 安全 泰国时间(UTC+07:00)
    每个 API 密钥域名验证(1 密钥 = 1 网站)——现有密钥照常可用
  14. 新增 泰国时间(UTC+07:00)
    可选 HMAC 请求签名——不开启则一切照旧
  15. 新增 泰国时间(UTC+07:00)
    API 密钥有效期、到期提醒和续期——密钥字符串不变
  16. 新增 泰国时间(UTC+07:00)
    所有服务支持 test 模式密钥(模拟、免费)

✅ 现有代码照常可用,无需修改

🛡️ 稳定性承诺:一次对接,长期可用

🚦 系统状态(GET /status)

随时查看 API 是否正常,无需密钥

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