Questions tagged [php-telegram-bot]

The telegram Bots are applications that can be used via telegram chat, the interaction is via Messages. The realization of these bots with PHP simplifies the work of a developer.

It is implemented by API and HTTP-based interface has all the methods of bot telegram (https://stackoverflow.com/tags/telegram-bot/info).

A simple way of use is:

define('BOT_TOKEN', '<YOUR-TOKEN>');
define('API_URL', 'https://api.telegram.org/bot'.BOT_TOKEN.'/');
define('FILE_URL', 'https://api.telegram.org/file/bot'.BOT_TOKEN.'/');

$content = file_get_contents("php://input");
$update = json_decode($content, true);

$message = isset($update['message']) ? $update['message'] : "";
$chatId = isset($message['chat']['id']) ? $message['chat']['id'] : "";
$text = isset($message['text']) ? $message['text'] : "";

header("Content-Type: application/json");
$parameters = array('chat_id' => $chatId, "text" => 'you wrote: '.$text);
$parameters["method"] = "sendMessage";
341 questions
2
votes
1 answer

disable notification for telegram bots when using reply keyboard markup in PHP

There is a simple way to disable notification when sending a message by send message method in telegram bots . but , How can we disable notification when using with reply_markup option? for example , $url =…
2
votes
1 answer

Telegram Bot PHP Create Dynamic Buttons

I am creating a manager bot that lists all admins of a certain channel or all managers of the bot or all the channels that bot have access to them ... so i created a database and succesfully connected to it from the bot what i'm going to do is : i.e…
2
votes
2 answers

php array in foreach loop

For a Telegram bot that I am building I want to return inline buttons dynamically depending the returned PHP PDO recordset Telegram API docs. Hardcoded a good function piece of code looks like the below. This is confirmed working. It return two…
AXTG
  • 58
  • 6
2
votes
1 answer

How to sendmessage after answercallbackquery in Telegram?

I'm trying to develop a Telegram Bot in PHP, but I failed to make my bot answer the user when he press an inline button. Can someone help me sending a message (sendMessage method) after calling the answerCallback method? Here's my last trial…
vavania
  • 61
  • 1
  • 5
2
votes
2 answers

Telegram Bot doesn't respond messages

i use server on Debian 8 with ISP 5. I have installed that lib: https://github.com/akalongman/php-telegram-bot. Webhook was set but bot doesn't respond messages and commands. Server hadn't logs, I do not know what the problem is :( I received a SSL…
MyZik
  • 220
  • 2
  • 15
2
votes
1 answer

php - telegram bot message width

currently I'm working on a telegram bot in php and Yii2 framework. I want to send a message that has a fixed width in telegram. if i send "Hi!" it should fill a line like this image: is it possible? I want the spaces after message so
wont do…
2
votes
1 answer

Create a new Telegram bot

I'm writing a Wordpress plugin using a Telegram Bot to send notification to a channel. I can send a command to my already created BOT in this way: https://api.telegram.org/bot[token]/[command] Is it possible to create a new BOT by code? e.g. sending…
2
votes
1 answer

updates in telegram bot switch()

I made this code in my .php file where I set webHook that works good. $token = "my token"; $website = "https://api.telegram.org/bot" . $token . "/"; $updates = file_get_contents("php://input"); $updates = json_decode($updates, true); $text =…
2
votes
1 answer

Is It possible to control a real telegram account by php and telegram api

I want to Control a Telegram Account With php ! is it possible to connect to telegram like that ? because i saw a robot like this in one of my groups ! that used a mobile number not botfather key !
Parsi
  • 23
  • 4
2
votes
1 answer

Send emoji via telegram bot

I am trying to send emojis via my telegram bot but I can not send it when I take it from an array or a variable. If I a do this in PHP, it works: $emoji = "\xF0\x9F\x98\x81"; echo $emoji; But I want to do something like this: $emoji =…
albertoperojo
  • 55
  • 1
  • 2
  • 5
1
vote
0 answers

How to change the width of inline buttons to chat width, instead of message width using js

I can't find a way to make the button to fit the chat are rather than the bot send.message text width. This is how it looks enter image description here The code for the first question is: bot.onText(/\/start/, (msg) => { const chatId =…
1
vote
0 answers

The problem of sending a photo with a link in Telegram-bot-sdk packages

When I try to send a photo or video using its link in telegram-bot-sdk package, I get the following error: I also use the latest version of the package (version 3). A path to local file, a URL, or a file resource should be uploaded using…
mr-mr7
  • 11
  • 1
1
vote
0 answers

Telegram bot return "403 Forbidden: bot can't initiate conversation with a user" with chat_join_request when send message

This is example of my code if ($update->isType('chat_join_request')) { $messageData = ['chat_id' =>$update->chatJoinRequest->from->id, 'text' => $post->post, …
1
vote
1 answer

Telegram Bot API getUpdates() does not deliver updates after user have not interacted with the bot for a few days

As a telegram bot api developer, I noticed a weird behaviour of the getUpdates() api method: If the user have not interacted with the bot for a few days, then the next time it sends a message to the bot, the message does not get delivered via the…
Meglio
  • 1,646
  • 2
  • 17
  • 33
1
vote
0 answers

Telegram bot parse mode HTML does not work in PHP

I am writing a telegram bot with php, and it is intended to send a news website to the user. The website has HTML codes inside with several attributes, e.g.

with many styles defined in line. I would like to send this code to telegram via the…