Chào mừng đến với dịch vụ Telegram API Secure Proxy. Gateway này cung cấp truy cập ổn định và đáng tin cậy tới Telegram API trong các khu vực bị hạn chế.
Thay thế địa chỉ Telegram API tiêu chuẩn bằng URL sau:
const sendTelegramMessage = (message) => {
const botToken = "YOUR_BOT_TOKEN";
const chatId = "YOUR_CHAT_ID";
const apiUrl = `https://aiko-api-proxy.pages.dev/api/bot${botToken}/sendMessage`;
const params = new URLSearchParams({
text: message,
chat_id: chatId,
parse_mode: "Markdown",
disable_web_page_preview: true
});
fetch(`${apiUrl}?${params}`)
.then(response => response.json())
.then(data => {
console.log("✅ Message sent successfully:", data);
})
.catch(error => {
console.error("❌ Error sending message:", error);
});
};
// Usage / Sử dụng
sendTelegramMessage("Hello from Secure API! 🚀");
import requests
import json
class TelegramAPI:
def __init__(self, bot_token):
self.bot_token = bot_token
self.base_url = f"https://aiko-api-proxy.pages.dev/api/bot{bot_token}"
def send_message(self, chat_id, message, parse_mode="Markdown"):
"""Send message via Telegram API / Gửi tin nhắn qua Telegram API"""
url = f"{self.base_url}/sendMessage"
payload = {
"chat_id": chat_id,
"text": message,
"parse_mode": parse_mode,
"disable_web_page_preview": True
}
try:
response = requests.post(url, json=payload)
response.raise_for_status()
result = response.json()
print("✅ Message sent successfully! / Tin nhắn đã được gửi thành công!")
return result
except requests.exceptions.RequestException as e:
print(f"❌ Error sending message / Lỗi khi gửi tin nhắn: {e}")
return None
# Usage / Sử dụng
if __name__ == "__main__":
bot = TelegramAPI("YOUR_BOT_TOKEN")
bot.send_message("YOUR_CHAT_ID", "Hello from Python! 🐍")
botToken = $botToken;
$this->baseUrl = "https://aiko-api-proxy.pages.dev/api/bot" . $botToken;
}
public function sendMessage($chatId, $message, $parseMode = "Markdown") {
$url = $this->baseUrl . "/sendMessage";
$data = [
'chat_id' => $chatId,
'text' => $message,
'parse_mode' => $parseMode,
'disable_web_page_preview' => true
];
$options = [
'http' => [
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data)
]
];
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if ($result === FALSE) {
echo "❌ Error sending message / Lỗi khi gửi tin nhắn\n";
return false;
}
echo "✅ Message sent successfully! / Tin nhắn đã được gửi thành công!\n";
return json_decode($result, true);
}
}
// Usage / Sử dụng
$telegram = new TelegramAPI("YOUR_BOT_TOKEN");
$telegram->sendMessage("YOUR_CHAT_ID", "Hello from PHP! 🐘");
?>
const express = require('express');
const axios = require('axios');
const app = express();
app.use(express.json());
class TelegramBot {
constructor(token) {
this.token = token;
this.baseURL = `https://aiko-api-proxy.pages.dev/api/bot${token}`;
}
async sendMessage(chatId, text, options = {}) {
try {
const response = await axios.post(`${this.baseURL}/sendMessage`, {
chat_id: chatId,
text: text,
parse_mode: options.parseMode || 'Markdown',
disable_web_page_preview: options.disablePreview || true,
...options
});
console.log('✅ Message sent successfully / Tin nhắn đã gửi thành công');
return response.data;
} catch (error) {
console.error('❌ Error sending message / Lỗi gửi tin nhắn:', error.message);
throw error;
}
}
async sendPhoto(chatId, photo, caption = '') {
try {
const response = await axios.post(`${this.baseURL}/sendPhoto`, {
chat_id: chatId,
photo: photo,
caption: caption,
parse_mode: 'Markdown'
});
console.log('✅ Photo sent successfully / Ảnh đã gửi thành công');
return response.data;
} catch (error) {
console.error('❌ Error sending photo / Lỗi gửi ảnh:', error.message);
throw error;
}
}
}
// Usage / Sử dụng
const bot = new TelegramBot('YOUR_BOT_TOKEN');
app.post('/webhook', async (req, res) => {
try {
const { message } = req.body;
if (message && message.text) {
await bot.sendMessage(message.chat.id,
`You sent: "${message.text}" 🤖 / Bạn đã gửi: "${message.text}" 🤖`);
}
res.sendStatus(200);
} catch (error) {
console.error('Webhook error:', error);
res.sendStatus(500);
}
});
app.listen(3000, () => {
console.log('🚀 Bot server running on port 3000');
});
# Send simple text message / Gửi tin nhắn text đơn giản
curl -X POST "https://aiko-api-proxy.pages.dev/api/botYOUR_BOT_TOKEN/sendMessage" \
-H "Content-Type: application/json" \
-d '{
"chat_id": "YOUR_CHAT_ID",
"text": "Hello from cURL! 🌐",
"parse_mode": "Markdown",
"disable_web_page_preview": true
}'
# Send message with inline keyboard / Gửi tin nhắn với keyboard inline
curl -X POST "https://aiko-api-proxy.pages.dev/api/botYOUR_BOT_TOKEN/sendMessage" \
-H "Content-Type: application/json" \
-d '{
"chat_id": "YOUR_CHAT_ID",
"text": "Choose an option / Chọn một tùy chọn:",
"reply_markup": {
"inline_keyboard": [
[
{"text": "✅ Agree / Đồng ý", "callback_data": "agree"},
{"text": "❌ Disagree / Từ chối", "callback_data": "disagree"}
]
]
}
}'
# Send photo with caption / Gửi ảnh với caption
curl -X POST "https://aiko-api-proxy.pages.dev/api/botYOUR_BOT_TOKEN/sendPhoto" \
-H "Content-Type: application/json" \
-d '{
"chat_id": "YOUR_CHAT_ID",
"photo": "https://example.com/image.jpg",
"caption": "Beautiful photo! 📸 / Bức ảnh đẹp! 📸"
}'
# Get bot information / Lấy thông tin về bot
curl -X GET "https://aiko-api-proxy.pages.dev/api/botYOUR_BOT_TOKEN/getMe"
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"time"
)
type TelegramBot struct {
Token string
BaseURL string
}
type SendMessageRequest struct {
ChatID string `json:"chat_id"`
Text string `json:"text"`
ParseMode string `json:"parse_mode,omitempty"`
DisableWebPagePreview bool `json:"disable_web_page_preview,omitempty"`
}
type TelegramResponse struct {
OK bool `json:"ok"`
Result interface{} `json:"result"`
}
func NewTelegramBot(token string) *TelegramBot {
return &TelegramBot{
Token: token,
BaseURL: fmt.Sprintf("https://aiko-api-proxy.pages.dev/api/bot%s", token),
}
}
func (bot *TelegramBot) SendMessage(chatID, message string) (*TelegramResponse, error) {
url := fmt.Sprintf("%s/sendMessage", bot.BaseURL)
payload := SendMessageRequest{
ChatID: chatID,
Text: message,
ParseMode: "Markdown",
DisableWebPagePreview: true,
}
jsonData, err := json.Marshal(payload)
if err != nil {
return nil, fmt.Errorf("❌ JSON marshal error / Lỗi marshal JSON: %v", err)
}
client := &http.Client{Timeout: 30 * time.Second}
resp, err := client.Post(url, "application/json", bytes.NewBuffer(jsonData))
if err != nil {
return nil, fmt.Errorf("❌ HTTP request error / Lỗi HTTP request: %v", err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("❌ Response read error / Lỗi đọc response: %v", err)
}
var telegramResp TelegramResponse
if err := json.Unmarshal(body, &telegramResp); err != nil {
return nil, fmt.Errorf("❌ Response unmarshal error / Lỗi unmarshal response: %v", err)
}
if !telegramResp.OK {
return nil, fmt.Errorf("❌ Telegram API returned error / Telegram API trả về lỗi")
}
fmt.Println("✅ Message sent successfully! / Tin nhắn đã được gửi thành công!")
return &telegramResp, nil
}
func main() {
bot := NewTelegramBot("YOUR_BOT_TOKEN")
_, err := bot.SendMessage("YOUR_CHAT_ID", "Hello from Go! 🐹")
if err != nil {
fmt.Printf("Error / Lỗi: %v\n", err)
return
}
fmt.Println("🚀 Go Bot is running! / Bot Go đang hoạt động!")
}