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

Telegram bot faq php

How to do this: bot: Enter your name i: myname bot: Enter your surname i: mysurname bot: Enter your question i: myquestion bot: enter file i: photo||audio||video or skip bot: thank you there are examples? I did not find what I need.
0
votes
1 answer

api Telegram webhook : how can delete new_chat_participant message

I created a bot via webhook method of api telegram and It's okay and working. but I want know how can delete any new_chat_participant messages before sending message by members. You know that telegram don't send request to your hook url until have…
Rai Rz
  • 493
  • 9
  • 22
0
votes
1 answer

Send Message in Telegram Messenger Bot

One simple question: is there any way to send a message to a user that never start chat with bot? For example can we send a message with username instead of chat id ?? simple pseudo code: sendMessage(@username, "Hello");
0
votes
1 answer

Select 1field from database in php

I have a problem with this code. I want select lang from Users table and if was fa send a message to user with telegram bot can u help me plz // Create connection $sconn = new mysqli($dbservername, $dbusername, $dbpassword, $dbname); // Check…
Mhdi
  • 11
  • 5
0
votes
2 answers

make a registration by telegram bot api

i'm making a bot and i'm using webhook. User should register on my bot in telegram. user /start the bot. the bot request name (for example) users write their name and send to bot the bot request for next field ... and i continues until last…
user7459213
0
votes
2 answers

Telegram Bot dynamic keyboard

I have one telegram code with sendMessage Method with text and keyboard. Its for finding music. My code is: $res_media=mysql_query("SELECT * FROM mv_media"); if(mysql_num_rows($res_media)!=0){ while($resualt_media =…
amir ntm
  • 84
  • 8
0
votes
1 answer

Laravel 5.5 telegram auth

I need to do authorization through telegram. The procedure is as follows: Generate a random string Write it into the cache We pass this line to the bot through the command /start random_str The bot sends a request to the server, where the system…
weijinnx
  • 61
  • 1
  • 1
  • 7
0
votes
1 answer

How to send photo in telegram bot in php 7.0.2

I have created a simple project to test sending photo to telegram bot in php 7, but nothing sends after starting the bot, however this project runs in php 5.3! Is there anything different in php 7 that I should use it? $message =…
M Taheri
  • 1
  • 2
  • 4
0
votes
1 answer

How to receive file from user in telegram bot?

i use Telegram SDK for laravel how to receive file from user ??
Amin Mohammad
  • 23
  • 1
  • 5
0
votes
1 answer

failed to open stream in my php source

i get an error in my php source...(im not master of php) $API_KEY = '246010911:AAFVhj7jc4kXUPfBH1**************'; $chatid = $update->callback_query->message->chat->id; $from_id2 = $update->callback_query->from->id; $get1 =…
Saeed
  • 1
  • 2
0
votes
1 answer

Message not receiving automatically for Telegram CHATBOT funciton using PHP

In order to integrate Telegram Chatbot using PHP, I have already followed below steps. Server with SSL certificate Webhook with working condition URL : https://api.telegram.org/bot/setWebhook?url=https://mywebsite.com/path/to/filename.php Created…
0
votes
2 answers

Insert data step by step in telegram bot

I am creating a telegram bot with php. I need to let user insert data step by step when they run the command /order. I do an example: User: /order Bot: I will help you to make an order Bot: Insert the name User: Ciccio (he has typed the name) Bot:…
Simone
  • 2,304
  • 6
  • 30
  • 79
0
votes
1 answer

how to promote users to supergroup using telegram bot api(PHP)?

I'm using this code to add some of my users to a supergroup but it doesn't work is there something wrong with it? function makereq($method,$datas=[]) { $url = "https://api.telegram.org/bot".API_KEY."/".$method; $ch = curl_init(); …
HamidR
  • 55
  • 1
  • 9
0
votes
1 answer

Telegram Bot Welcome greetings message

"How to send welcome greetings message using Bot, in Telegram"? Acctually i create new bot in telegram. and now i want , when new user start my bot, my bot send him Welcome greetings message? is it possible with "getupdates" method or i should use…
mayank
  • 31
  • 1
  • 6
0
votes
1 answer

Telegram api get chat_id from php

Is it possible to get the chat_id directly without using the telegram client ? We have a mobile contact list and we would like to get the chat_id of each one. Regards
Fran Rod
  • 586
  • 4
  • 14
  • 26