Closed farmaworld closed 4 years ago
What version of the bot are you using? Also, did you install it correctly with composer and include the autoloader?
i installed with composer, i don,t have the version.. where i search the version?
You can see the version in vendor/longman/telegram-bot/src/Telegram.php
file, a variable called $version
0.62.0
vendor ------------------composer ____------------------guzzlettp ____------------------longman---------------telegram-bot-----src ____------------------psr ____------------------ralouphie ____------------------symphony ____-------------------autoload.php my_PHP_file
Could you share your my_PHP_file
file please?
Remember to remove your API Key, bot username and any other credentials!
in my path dir where is vendor i have: hook.php manager.php GetUpadatesCLI.php set.php unset.php GetUpdates work fine and also set and unset php file now in this direcotory i want create my file to send any message to the bot but i don't undesrtund how make this file please if you have any example thanks
<?php
//Composer Loader
$loader = (require __DIR__ . '/vendor/autoload.php');
$API_KEY = 'your_bot_api_key';
$BOT_NAME = 'namebot';
//$COMMANDS_FOLDER = __DIR__.'/Commands/';
//$credentials = array('host'=>'localhost', 'user'=>'dbuser', 'password'=>'dbpass', 'database'=>'dbname');
try {
// create Telegram API object
$telegram = new Longman\TelegramBot\Telegram($API_KEY, $BOT_NAME);
// ......my code................
$telegram->handle();
} catch (Longman\TelegramBot\Exception\TelegramException $e) {
// log telegram errors
// echo $e;
}
@farmaworld Have you set the webhook URL in set.php
correctly, to point to your hook.php
file?
That is important, so that the webhook called by Telegram points to the correct hook.
You can also get the status of your webhook with the getWebhookInfo
method, to check if there are any errors:
https://core.telegram.org/bots/api#getwebhookinfo
i connect all file whit database and work fine. everythink i write in the chat box i save in the database. i don't understund how send message? i inizialize a new telegram object new Telegram($API_KEY, $BOT_NAME); but i don't have a chat_it
$result = Request::sendPhoto([
'chat_id' => $chat_id,
'photo' => Request::encodeFile('/path/to/pic.jpg'),
]);
To send a message (or photo or whatever) you must have a chat ID.
Then the code you have above will work :+1:
You can also simplify it a bit:
$result = Request::sendPhoto([
'chat_id' => $chat_id,
'photo' => '/path/to/pic.jpg',
]);
i don't understund why i have this error thanks