I am making a personal small PHP Telegram Bot. But there is a problem I want to make a function which helps me to reply to user just by replying to the message he sent. Like when a user sends a message in the Bot it will forward the message to me.I want to reply to this user by replying to the message he sent.
I tried with the help of Telegram Bot API but didnt succeed.
Here is the forwardMessage function which works
//forward msg
function forwardMessage($adminid,$chatId, $message_id){
$url = $GLOBALS["website"]."/forwardMessage
chat_id=".$adminid."&from_chat_id=".$chatId."&message_id=".$message_id."&parse_mode=HTML";
file_get_contents($url);
}
I tried to make a sendReply function with the help of API but it does not work
//send reply
function sendReply($userId,$message, $reply_to_message_id){
$url = $GLOBALS["website"]."/sendMessage?
chat_id=".$userId."&text=".$message."&reply_to_message_id=".$reply_to_message_id."&parse_mode=HTML";
file_get_contents($url);
}
2
Answers
By your Question, I guess you want to make a System like Livegram Bot. Here is the Code. DM Me on Telegram @NinjaNaveen if you Need Further Help 🙂
It seems your code has some errors in declaring values, but you can try this function: