🚀 เชื่อมต่อระบบโรงเรียนเข้ากับ Telegram
ระบบเปิดให้บริการ REST API สำหรับให้โปรแกรมต่างๆ ในโรงเรียน (เช่น ระบบจองห้อง Room-KC, ระบบบันทึกเวลา, ระบบลา, ระบบตารางสอน) สามารถส่งข้อความแจ้งเตือนหาครูได้ทันทีโดยใช้เพียงรหัสครู (TeacCode)
POST https://tele.chanupatham.ac.th/api/send_notify.php
JSON Body
API Key Protected
POST
/api/send_notify.php
ใช้ส่งข้อความแจ้งเตือนไปยัง Telegram ของครู
Parameters (JSON หรือ Form POST)
| Parameter | Type | จำเป็น | คำอธิบาย |
|---|---|---|---|
| api_key | string | จำเป็น | รหัส API Key ของระบบ (หรือส่งผ่าน Header Authorization: Bearer <key>) |
| message | string | จำเป็น | ข้อความแจ้งเตือน รองรับ HTML tags เช่น <b>, <i>, <code>, <a> |
| teac_code | string | เลือก 1 อย่าง | รหัสครูผู้รับ เช่น "101" หรือ "01" |
| teac_codes | array | เลือก 1 อย่าง | ส่งหลายคนพร้อมกัน เช่น ["101", "01", "204"] |
| department | string | เลือก 1 อย่าง | ส่งทั้งกลุ่มสาระฯ เช่น "กลุ่มสาระฯ ภาษาไทย" |
| app_name | string | ตัวเลือก | ชื่อโปรแกรมต้นทาง เช่น "ระบบจองห้อง (Room)" (สำหรับบันทึก Log) |
ตัวอย่างโค้ดเรียกใช้งาน (Code Examples)
PHP (cURL)
สำหรับระบบ Room หรือเว็บ PHP อื่นๆ
$data = [
'api_key' => 'kc_notify_7dd87d35bced92d8',
'teac_code' => '101', // รหัสครู
'app_name' => 'ระบบจองห้อง (Room-KC)',
'message' => "📅 คำขอจองห้องได้รับการอนุมัติแล้ว\n" .
"• ห้อง: ห้องประชุม 1\n" .
"• เวลา: 28/08/2026 09:00 - 12:00\n" .
"• สถานะ: อนุมัติแล้ว"
];
$ch = curl_init('https://tele.chanupatham.ac.th/api/send_notify.php');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
if ($result && $result['ok']) {
// ส่งสำเร็จ
}
Python
สำหรับ Script / AI / Automation
import requests
url = "https://tele.chanupatham.ac.th/api/send_notify.php"
payload = {
"api_key": "kc_notify_7dd87d35bced92d8",
"teac_code": "101",
"app_name": "Python Attendance System",
"message": "⏰ แจ้งเตือน: มีการสแกนนิ้วเข้าปฏิบัติราชการเวลา 07:45 น."
}
response = requests.post(url, json=payload)
print(response.json())
cURL Command
curl -X POST "https://tele.chanupatham.ac.th/api/send_notify.php" \
-H "Content-Type: application/json" \
-d '{
"api_key": "kc_notify_7dd87d35bced92d8",
"teac_code": "101",
"app_name": "Test Terminal",
"message": "👋 ทดสอบการส่งข้อความผ่าน cURL"
}'