php-telegram-bot / core

PHP Telegram Bot based on the official Telegram Bot API
MIT License
3.9k stars 953 forks source link

How to setup and running #280

Closed devlifeX closed 8 years ago

devlifeX commented 8 years ago

Hi guys Before any thing i like to appreciate your work. it's cool, use OOP and good documentation. I read couple time instruction and explore example But i can not find a way to running your delicious library. I have HTTPS domain (check bot with official telegram example, no problem with that) I have some questions about setup and running.

Questions

1) What is next after 'require composer' and put set.php and hook.php? 2) I need run this url? What should I do? https://api.telegram.org/bot<token>/setWebhook?url=https://mydomain.com/hook.php 3) How telegram communicate with your library? 4) Your script find automatically new custom command?

And at the end i ask you for put operational example with all features

noplanman commented 8 years ago

Hi @devlifeX

Thanks for the kind words! 🙏

1) What is next after 'require composer' and put set.php and hook.php?

After composer has downloaded all the necessary components and you have put the set.php and hook.php in the root folder, go to answer 2. (Be sure to insert your bot API key and name to both files, and the correct Webhook URL to set.php)

2) I need run this url? What should I do? https://api.telegram.org/bot/setWebhook?url=https://mydomain.com/hook.php

Not quite. All you need to do now, is open https://mydomain.com/set.php in your browser. This should give you the message Webhook was set. That's it! (To unset the Webhook, just get the unset.php example file and run that!)

3) How telegram communicate with your library?

This is where the magic of the Webhook happens. When your bot gets a message, Telegram sends an update to the hook.php file (defined in set.php), which then handles it.

4) Your script find automatically new custom command?

Yes, you just need to tell the library where the custom commands can be found.

And at the end i ask you for put operational example with all features

The bot already has a bunch of commands included. When you have it up and running, just send the /help command to see which ones are available.

Good luck and have fun! 👍

frengkys commented 8 years ago

hey noplanman, how to use this library? when i took some example code on example folder and run it, it is become error

"mydomain.com is currently unable to handle this request. HTTP ERROR 500"

//btw, i've set the webhook already //and my goal is just wanna send message to the bot and mybot respond it...

noplanman commented 8 years ago

@frengkys Have you followed the readme exactly?

If yes, I need more info to find out what's going wrong.

When you directly call the URL to your https://example.com/hook.php file, do you get any output?

devlifeX commented 8 years ago

@frengkys i had issue with runing this library, but this library is OK, probably your server has problem like (php configuration issue, web server configuration issue or even HTTPS issue) you can track your error and access log on your server (do not forget in this case check SSL log) in my case i was missing install php-mbstring ( i explained it here)

frengkys commented 8 years ago

hook.php is blank, i think there is something wrong with my server configuration

noplanman commented 8 years ago

In the catch block of your hook.php, uncomment (or add) the following line to output the error message:

} catch (Longman\TelegramBot\Exception\TelegramLogException $e) {
    echo $e;
}

Then try to figure out the problem or post the error here.

MBoretto commented 8 years ago

closing there