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
0
votes
2 answers

Telegram Bot with Laravel

I want to build a bot in Telegram with Laravel 5.3, but I have some problems... My site is located on the computer. How can I register some easy commands (/help, /start)? When I'm writing to bot, it doesn't respond to commands :( But I can get the…
MyZik
  • 220
  • 2
  • 15
0
votes
1 answer

message text not returned in getUpdates telegram bot

I am using: https://api.telegram.org/[bot_id]/getUpdates to retrieve the recent updates. It returns a message object, however it does not include the "text" field of the message. "message": { "message_id": 5, "from": { …
0
votes
1 answer

How to know if message is continuation of conversation?

This might be a stupid question, but I haven't come across any mention of it in the docs. How do I know when a message is a continuation of a previous interaction? For example, with BotFather, you send /setdescription and BotFather tells you to send…
m52go
  • 343
  • 1
  • 3
  • 14
0
votes
1 answer

Create new telegram chat using bot

Can Telegram bot answer to a single user from the group if this chat (user with bot) wasn't created before? In other words I need to create a new chat with user. Method ...sendMessage?chat_id=$userId... works only when the user has allready chatted…
Rus
  • 718
  • 2
  • 6
  • 19
0
votes
1 answer

how to use move_uploaded_file to save file from getfile in telegram

How to use move_uploaded_file to save file from Get File in telegram. My code is : move_uploaded_file("https://api.telegram.org/file/ botMYTOKEN/photo/file_4.jpg", "/images/1.jpg");
Ebrahim
  • 13
  • 4
0
votes
1 answer

Wrong response from the webhook: 400 Bad Request

I'm recently tried to use webhook to get update from telegram. my program work correctly whit getUpdates(). but when i set webhook i got "Wrong response from the webhook: 400 Bad Request" error when try to check status of webhook by…
Aminkt
  • 612
  • 9
  • 25
0
votes
2 answers

telegram bot ,How to make bigger buttons with emoj caption

I'm trying to make this kind of inlineKeyboardButtons : https://i.stack.imgur.com/sHSTA.png Which is bigger in width and has emojis inside it. How can I do so ? Thanks
j.hamid
  • 3
  • 4
0
votes
2 answers

Telegram php: answer to a callback_query

I've created a bot in PHP in Telegram where I've 2 buttons inline. I receive right the click but after how I can send back another message? With the code below I can send a message but it doesn't work in this case. $content =…
0
votes
1 answer

Contact us button in php telegram bot

I created a button in my telegram bot named "contact us". How can I get the member's message after pressing "contact us" button ?
amin roshani
  • 389
  • 4
  • 11
0
votes
1 answer

Telegram Bot api - how to send my self signed certificated file using curl?

I want to create a BOT for Telegram, but I have issues in sending my public.key file to telegram. I have a vps and the last version of directadmin installed on it. I purchased a free IP and assigned it to one of "my users" which I'm going to use for…
user5601721
0
votes
0 answers

Speed up Telegram Bot API in PHP

I have used PHP in order to write a Telegram bot that uses webhook which means that the PHP file is called for each update. I have used curl in order to post JSON to https://api.telegram.org. When I send a message in my PHP file, it responds in…
Matin Lotfaliee
  • 1,745
  • 2
  • 21
  • 43
0
votes
1 answer

Can't get updated messages from Telegram Bot after script started

I'm trying to create a script to operate my bot via Bot API, I'm using simple PHP file on my server, which has a set Webhook so that Telegram refers to this file each time when message is received. But the problem is that I'm unable to get a new…
VItazzz
  • 11
  • 1
0
votes
2 answers

Telegram Bot API: "username" field is missing

I want to read user names from receiving updates however but I face an special issue. For some users, $message['from']['username'] contains a Telegram User Name however for some users this parameter is not defined. How can I reliably receive user…
VSB
  • 9,825
  • 16
  • 72
  • 145
-1
votes
0 answers

a php telegram bot in insert value in table

I am trying to insert some value in a table. but it does not work! how can I fix the problem? here is my code: $servername = "localhost" $username = "****" $password = "****" $dbname = "****" $conn = new `($servername, $username, $password,…
-1
votes
1 answer

How to send emoji (not custom) throw the Telegram API

I tried few variants. Like here: How to send Emoji with Telegram Bot API? python telegram telethon how to send emoji And each variant of encoding from this page https://www.fileformat.info/info/unicode/char/1f4b5/index.htm But nothing helped for…