curl Node.js PHP Python
คัดลอก
curl -X POST https://api.tungkao.com/v1/telegram/send \
-H "Authorization: Bearer $TUNGKAO_KEY" \
-H "Content-Type: application/json" \
-d '{"ref":"member-1001","text":"<b>ยอดเข้าแล้ว</b> 500 บาท","parse_mode":"HTML","button":{"text":"ดูรายการ","url":"https://yourshop.com/orders/1"}}'// Node.js 18+ (ไม่ต้องติดตั้งอะไรเพิ่ม)
const res = await fetch("https://api.tungkao.com/v1/telegram/send", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.TUNGKAO_KEY}`, "Content-Type": "application/json" },
body: JSON.stringify({
"ref": "member-1001",
"text": "<b>ยอดเข้าแล้ว</b> 500 บาท",
"parse_mode": "HTML",
"button": {
"text": "ดูรายการ",
"url": "https://yourshop.com/orders/1"
}
}),
});
const data = await res.json();
console.log(data);<?php
$ch = curl_init("https://api.tungkao.com/v1/telegram/send");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("TUNGKAO_KEY"), "Content-Type: application/json"],
CURLOPT_POSTFIELDS => json_encode([
"ref" => "member-1001",
"text" => "<b>ยอดเข้าแล้ว</b> 500 บาท",
"parse_mode" => "HTML",
"button" => [
"text" => "ดูรายการ",
"url" => "https://yourshop.com/orders/1"
]
]),
]);
$data = json_decode(curl_exec($ch), true);
print_r($data);import os, requests # pip install requests
r = requests.post(
"https://api.tungkao.com/v1/telegram/send",
headers={"Authorization": f"Bearer {os.environ['TUNGKAO_KEY']}"},
json={
"ref": "member-1001",
"text": "<b>ยอดเข้าแล้ว</b> 500 บาท",
"parse_mode": "HTML",
"button": {
"text": "ดูรายการ",
"url": "https://yourshop.com/orders/1"
}
},
timeout=30,
)
print(r.json())