Closed fwag closed 6 years ago
Try include telegram.php;
I don't think depends on the include because I'm using composer and the include follows the doc. Furthermore I've tried in polling and it works.
I've been able to get the chat_id with the $telegram->getMe(). I have hardcoded the chat_id but I'm able to receive the message sent with sendMessage only if I write the "/start" command on the bot chat. Do you know why ?
i need to see your bot script code
I could not use the id provided by getMe(). I dumped the error response and it was 403 "Forbidden: bot can't send messages to bots". The solution was to go to Telegram and search for the bot called "userinfobot" with the questionmark as an avatar. Click start and it gives you your userid. Use that, and you will start receiving messages from your bot :-)
You can try to dump the $result and see if the webhook is sending something strange
I've uploaded the composer downloaded dir on my ftp repo and added the following code in a page called send_alert.php
`<?php
include (DIR . '/vendor/autoload.php');
date_default_timezone_set("Europe/Rome");
$token = "4...."; $telegram = new Telegram($token);
$chat_id = $telegram->ChatID();
var_dump($chat_id);
$result = $telegram->getData(); $text = $result['message'] ['text']; $chat_id = $result['message'] ['chat']['id']; $content = array('chat_id' => $chat_id, 'text' => 'Test'); $telegram->sendMessage($content);
?>`
then I've added the webhook with:
https://api.telegram.org/bot4161.../setWebhook?url=https://www.mywebsite.altervista.org/AlertBot/send_alert.php
but I got the error:
description: Bad Request: chat_id is empty inside TelegramErrorLogger.txt
Do you know why ?