<?php
function sendMessage($chatID, $messaggio, $token, $message_id = null) {
echo "sending message to " . $chatID . "\n";
$url = "https://api.telegram.org/bot" . $token . "/sendMessage?chat_id=" . $chatID;
$url = $url . "&text=" . urlencode($messaggio);
if ($message_id) {
$url = $url . "&reply_to_message_id=" . $message_id;
}
$ch = curl_init();
$optArray = array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true
);
curl_setopt_array($ch, $optArray);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
function sendPhoto($chatID, $messaggio, $token) {
echo "sending message to " . $chatID . "\n";
$url = "https://api.telegram.org/bot" . $token . "/sendPhoto?chat_id=" . $chatID;
$url = $url . "&photo=http://site.ru/img.png&caption=Тут кароче до 200символов типа ФИО можно грузить и город)";
$ch = curl_init();
$optArray = array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true
);
curl_setopt_array($ch, $optArray);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
$obj = new stdClass();
$obj->token = 'ТУТ ТОКЕН';
$obj->chat = '@my_CHAnnel';
$obj->message = isset($_GET['m']) ? $_GET['m'] : 'нет гет параметра';
$photo = sendPhoto($obj->chat, $obj->message, $obj->token);
$result = json_decode($photo);
$img_id = $result->result->message_id;
var_dump(sendMessage($obj->chat, $obj->message, $obj->token, $img_id));