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

In webhook what is has_custom_certificate: false?

I have a teegram bot that has an issue because send many times same message. Maybe because bot don't say to telegram the first operation is correct. Is really slowly and so telegram send again message. I'm tring to understand the reason but…
0
votes
1 answer

how to make a response to the inline query in telegram bot with unreal4u telegram api

I'm using unreal4u telegram-API package. I want to send the result of an inline query I do the same that the package owner said but the response that the code makes don't respond that it's supposed to. public function…
0
votes
1 answer

How to solve a error with callback_data or method in PHP

The idea is to have some buttons to do something, I got the following code, and something is wrong with the method (sendMessage) or callback_data because I received a undefined index error in all the rows where is the $message, if I use a url…
I LB
  • 11
  • 3
0
votes
1 answer

How to get delete account code from telegram msg

I need to get the code from this msg using php and username changes according to user Web login code. Dear username, we received a request from your account to log in on my.telegram.org. This is your login code: nJB2G5Yb8Rs Do not give this code…
Skora
  • 107
  • 11
0
votes
1 answer

Telegram bot stops working after couple of months/weeks

My Telegram bot has php backend. I've set the hook based on the official guide. Many times the bot stops responding and I realize Telegram server doesn't trigger assigned web-hook. When I delete that bot and make a new bot with the same ID, problem…
Ali Has
  • 598
  • 1
  • 8
  • 24
0
votes
1 answer

how can send inlineKeyboard with answerInlineQuery Telegram bot

I have a telegram bot with irazasyed package and set it to 'inline mode' now when user type (@botid aboutus) bot show text for user like below : now i need when user click to that item, bot send inlineKeyboard to user like below :
0
votes
2 answers

How to fix curl_error: SSL: no alternative certificate subject name matches target host name 'api.telegram.org'

I am using telegram.php to connect my bot. When I use sendmessage all of thing is ok in my logs but I do not receive anything from the bot. When I check my log there is a problem like this: ok: False curl_error_code: 51 curl_error: …
0
votes
1 answer

Inline bot doesn't show anything

I try to setup an inline bot that send just 1 picture for user query. All seems to be working, but bot doesn't show any results in app, not even switch_pm_text I give to him. I think I somehow messed with results array? I parse all the incoming…
0
votes
1 answer

PHP class use other classes from composer

I made a class which autoloads with psr-4. In this class I wanted to use classes from some libraries that I downloaded with composer the problem is that I can't seem to figure it out. Class:
Leonardo Drici
  • 749
  • 3
  • 11
  • 32
0
votes
0 answers

How to update multiple rows in mysql using while loop in php

I have a telegram bot that collect telegram channel username,subscriber count and etc.. Now i need to update subscriber count of all telegram channel in my database using telegram api. see the below code.That only updating first row in…
0
votes
0 answers

How to solve the error while inserting subscriber count using telegram bot api

When i send message to my bot as /addchannel @username it returns no error but the channel subscriber count was not inserted in my database $ex = explode("/addchannel", $text); $im = implode("", $ex); …
0
votes
1 answer

Sending voice to Telegram through PHP app

Here is the situation. I have an Android app, which can send voice file with HTTP POST anywhere I specify. Also I would like to download these voice files to Telegram bot automatically. I wrote a PHP bot and I can accept and translate to Telegram…
0
votes
1 answer

how can i get userchat id in telegram bot using phone number in php

I need to get user id of a specific phonenumber group and for this i user SendContact Telegram bot api method to share my phone numbers with my own chat id , but when i get telegram server response i don't get any chat id however my phone numbers…
0
votes
1 answer

How to sendMessage directly to any User (i have user_id) by bot using Telegram Bot Api

I've User ID's of multiple people. I want to send them a message using my BOT but, the problem is I don't have chat_id of an individual user because they haven't initiated a chat with the bot. Is there a way I can send a Direct message using User_ID…
0
votes
1 answer

how to create a button that makes an http request without visting link on telegram bot

I'm trying to create a bot that shows a button. once the button is clicked I want the request to be done without user having to actually visit the link. This is the current function I've. function show_button($db, $chatID, $id) { $cols =…