Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue: ❓ Support Question #23

Closed
Theolodewijk opened this issue Mar 2, 2020 · 2 comments
Closed

Issue: ❓ Support Question #23

Theolodewijk opened this issue Mar 2, 2020 · 2 comments
Labels
question Further information is requested

Comments

@Theolodewijk
Copy link

I tray to get some info bot Telegram don't reply support tickets!

Can you help me with Telegram. so that I am sent in the right direction.

I work for a government organization and we have a weekly exercise, now I would like to simplify this with, for example, a poll or something else where if someone responds to that I get a feedback via the telegram API.

I want to use PHP for this but see many options on the Telegram website https://core.telegram.org/bots/samples#php but now which one is and is not suitable for this and there is a little explanation somewhere how to find it tackles this?

https://telegram.org/blog/polls-2-0-vmq

Greetings Theo

@Big-Shark
Copy link
Member

Hi @Theolodewijk

I hope this helps you, this is a simple script send poll in a chat room.

$botKey = '<bot key>';

$requestFactory = new Http\Factory\Guzzle\RequestFactory();
$streamFactory = new Http\Factory\Guzzle\StreamFactory();
$client = new Http\Adapter\Guzzle6\Client();

$apiClient = new \TgBotApi\BotApiBase\ApiClient($requestFactory, $streamFactory, $client);
$bot = new \TgBotApi\BotApiBase\BotApi($botKey, $apiClient, new \TgBotApi\BotApiBase\BotApiNormalizer());

$chatId = '<user id>';

$bot->send(SendPollMethod::create($chatId, 'question', ['v1', 'v2']));

If you need more information, please, ask me or @greenplugin , and we can try help you.

@greenplugin greenplugin added the question Further information is requested label Mar 3, 2020
@greenplugin
Copy link
Member

Also you can use SendPoolMethod as it described in official api:
https://core.telegram.org/bots/api#sendpoll
and receive updates in webhooks like this:

$fetcher = new \TgBotApi\BotApiBase\WebhookFetcher(new \TgBotApi\BotApiBase\BotApiNormalizer());
$update = $fetcher->fetch(file_get_contents('php://input'));
$pool = $update->poll;

'poll' property of update will contain poll object as is in documentation
https://core.telegram.org/bots/api#poll

Also you can use GetUpdates method to get updates without webhook

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants