$token = "Токен бота";
$data = [
'text' => 'Сообщение',
'chat_id' => 'ид человека, которому прийдут логи'
];
file_get_contents("https://api.telegram.org/bot".$token."/sendMessage?" . http_build_query($data) )
$params = [
'chat_id'=>$receiver,//ид кому отправлять
'parse_mode'=>'html',
'text'=>$message//сообщение
];
$ch = curl_init("https://api.telegram.org/bot" . $token . "/sendMessage");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
$response = curl_exec($ch);
curl_close($ch);
Вот тебе пример курлыком и пост запросом
PHP:$params = [ 'chat_id'=>$receiver,//ид кому отправлять 'parse_mode'=>'html', 'text'=>$message//сообщение ]; $ch = curl_init("https://api.telegram.org/bot" . $token . "/sendMessage"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_VERBOSE, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS,$params); $response = curl_exec($ch); curl_close($ch);
с помощью file_get_contents что ли?) Не факт, что так будет лучше.Расписано конечно годно, но - сделаю можно куда лучше при этом уместив в пару строк.
Не-а)с помощью file_get_contents что ли?) Не факт, что так будет лучше.
Через сокеты?Не-а)
хм, интересно. показывай эти 2 строки)Не-а)
<?php
/* В переменной token указываем токен бота который выдал @BotFather */
$token = "Токен бота";
/* В переменной chat_id указываем либо ваш личный id либо id группы куда будут лететь уведомления (созданного бота нужно будет добавить в группу) */
$chat_id = "Chat_id"; // Chat_id / Group_id
$arr = array(
' ' => 'Текст заголовка',
'Обычный текст: ',
);
foreach($arr as $key => $value) {
$txt .= "<b>".$key."</b> ".$value."%0A";
};
$sendToTelegram = fopen("https://api.telegram.org/bot{$token}/sendMessage?chat_id={$chat_id}&parse_mode=html&text={$txt}","r");
?>