-
Notifications
You must be signed in to change notification settings - Fork 0
/
webhook.php
24 lines (19 loc) · 885 Bytes
/
webhook.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
$telegramBotToken = 'YOUR_TELEGRAM_BOT_TOKEN';
$chatID = 'YOUR_TELEGRAM_CHAT_ID';
// POST ile gelen veriyi alıyoruz.
// Bu örnekte, 'file_get_contents("php://input")' yerine '$_POST' veya '$_REQUEST' kullanılmıyor,
// çünkü TradingView 'Content-Type' olarak 'text/plain' gönderiyor.
// Bu yüzden veriyi doğrudan okumak gerekiyor.
$messageText = file_get_contents("php://input");
// Eğer mesaj boşsa, varsayılan bir metin belirleyebilirsiniz.
if (empty($messageText)) {
$messageText = "Bir alarm tetiklendi, ancak mesaj içeriği alınamadı.";
}
// Mesajı URL'ye uygun hale getiriyoruz.
$message = urlencode($messageText);
// Telegram'a mesaj gönder
$response = file_get_contents("https://api.telegram.org/bot$telegramBotToken/sendMessage?chat_id=$chatID&text=$message");
// Telegram API'sinden gelen yanıtı kontrol edebilirsiniz.
// echo $response;
?>