เอกสารอ้างอิง API
เปรียบเทียบผู้ให้บริการ

การให้สิทธิ์ Telegram

Telegram รองรับ code (รหัสยืนยัน), qrcode (QR) และ session (นำเข้า session) ทั้งสามใช้ /v1/accounts และ auth endpoints มาตรฐาน: /auth/start, /auth/code, /auth/password, /auth/qr/start, /auth/qr/check, /auth/session

code

ไหลรหัสยืนยัน: เซิร์ฟเวอร์ขอรหัสจาก Telegram ผู้ใช้รับผ่าน SMS หรือในแอปแล้วส่งกลับมา

  1. 1. POST /v1/accounts โดยใช้ provider=telegram, auth_mode=code และ provider_data ที่มี api_id, api_hash, phone
  2. 2. POST /v1/accounts/{account_id}/auth/start เพื่อขอให้ Telegram ส่งรหัสยืนยัน
  3. 3. เมื่อผู้ใช้ได้รหัส POST /v1/accounts/{account_id}/auth/code พร้อมรหัส
  4. 4. หากบัญชีเปิด 2FA ค่า status จะเป็น awaiting_password — POST /v1/accounts/{account_id}/auth/password เพื่อส่งรหัสผ่าน
  5. 5. เมื่อสำเร็จ POST /v1/accounts/{account_id}/runtime/start เพื่อทำให้บัญชีออนไลน์
  • provider_data.api_idTelegram App ID ที่ได้จาก my.telegram.org จำเป็นสำหรับทุกโหมดของ Telegram
  • provider_data.api_hashTelegram App Hash ที่ได้จาก my.telegram.org จำเป็นสำหรับทุกโหมดของ Telegram
  • provider_data.phoneหมายเลขโทรศัพท์รูปแบบ E.164 จำเป็นเฉพาะโหมด code

qrcode

flow QR: รับ QR token แล้วให้ผู้ใช้สแกนในแอป Telegram

  1. 1. POST /v1/accounts โดยใช้ provider=telegram, auth_mode=qrcode และ provider_data.api_id / api_hash
  2. 2. POST /v1/accounts/{account_id}/auth/qr/start — การตอบกลับจะมี QR token สำหรับนำไปแสดง
  3. 3. Poll POST /v1/accounts/{account_id}/auth/qr/check จนกว่า status=authorized QR หมดอายุประมาณ 30 วินาที ต้องเรียก qr/start อีกครั้งเพื่อรีเฟรช
  4. 4. เมื่อสำเร็จ POST /v1/accounts/{account_id}/runtime/start
  • provider_data.api_idTelegram App ID ที่ได้จาก my.telegram.org จำเป็นสำหรับทุกโหมดของ Telegram
  • provider_data.api_hashTelegram App Hash ที่ได้จาก my.telegram.org จำเป็นสำหรับทุกโหมดของ Telegram

session

flow นำเข้า session: นำ session Telegram ที่ได้รับอนุญาตแล้วเข้า UnifyPort

  1. 1. POST /v1/accounts โดยใช้ provider=telegram, auth_mode=session
  2. 2. POST /v1/accounts/{account_id}/auth/session โดย params.session_url ชี้ไปยังไฟล์ .session ที่ดาวน์โหลดได้
  3. 3. เมื่อการ import ยืนยันว่า session ใช้ได้ POST /v1/accounts/{account_id}/runtime/start
  • params.session_urlURL หรือ reference ของ session Telegram ที่มีอยู่

หมายเหตุ

  • รหัสผ่าน 2FA ไม่มี state ระหว่างการพยายาม หากใส่ผิด ให้ cancel แล้วเรียก /auth/qr/start หรือ /auth/start ใหม่
  • QR token หมดอายุประมาณ 30 วินาที เรียก qr/start อีกครั้งเพื่อรีเฟรช UI ต้อง render QR ใหม่ทุกครั้ง
  • URL webhook จะถูก inject อัตโนมัติเมื่อ config บัญชี การเปลี่ยนสถานะการให้สิทธิ์และอีเวนต์ login มาที่ webhook เดียวกับข้อความขาเข้า