Eleirbag89 / TelegramBotPHP

A very simple PHP Telegram Bot API for sending messages.
http://eleirbag89.github.io/TelegramBotPHP
MIT License
800 stars 340 forks source link

way to debug bot #244

Closed swim89 closed 3 years ago

swim89 commented 3 years ago

Hi guys! I'm having some issues on bot, it doesn't answer me on telegram but the code is correct (it answered in the past and nothing has changed).

How can I debug the code to see if everything is good? Could be a problem of SSL certificate?

This is the simple code I used to test the bot after the issue:

require '../vendor/autoload.php';

$BOT_TOKEN = "[bot:token]";

$telegram = new Telegram($BOT_TOKEN);

$result = $telegram->getData();
$text = $result['message']['text'];
$chat_id = $result['message']['chat']['id'];

if ($text == "/test") {
    $msg = 'Test is good';
    $content = array('chat_id' => $chat_id, 'text' => $msg);
    $telegram->sendMessage($content);
}

But it doesn't answer me :(

Eleirbag89 commented 3 years ago

Using the default configuration TelegramErrorLogger should write a logfile with alla the errors, can you post it ?

swim89 commented 3 years ago

Hi, it doesn’t write in the file if I run the bot from telegram. If I launch it from the browser it writes there but I can’t run commands like “/start” or others…

Eleirbag89 commented 3 years ago

The webhook url is correctly configured ? How are you managing the SSL certificate?

swim89 commented 3 years ago

How can I check both of your requests?

Eleirbag89 commented 3 years ago

https://core.telegram.org/bots/api GetWebhookInfo should give you the URL where Telegram will forward the requests and should ne the address of the webserver running your bot script.

You van view the info of the SSL CERT by navigating with https on your bot script url

swim89 commented 3 years ago

Oh sure, already checked them. The url is correct and the SSL certificate is issued by zerossl.com

Eleirbag89 commented 3 years ago

It's strange. Try to pur this at the start of your script: file_put_contents("test.txt", "Test")

And check if the file is written after you send a message to your bot.

If not I'll check with my hosting provider if it blocks incoming connections from the telegram's servers.

swim89 commented 3 years ago

Same. If I run the code from the browser it creates the file you suggested. Not from the bot. I tried to send "/start" but nothing was created.

Mohsen322 commented 3 years ago

hello there. i can help you right now on my telegram id. im here: @***

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

swim89 commented 2 years ago

It's strange. Try to pur this at the start of your script: file_put_contents("test.txt", "Test")

And check if the file is written after you send a message to your bot.

If not I'll check with my hosting provider if it blocks incoming connections from the telegram's servers.

Hi @Eleirbag89 I tried it but nothing was written into the file...any other suggestions?