Closed ScotterMonk closed 3 years ago
$telegram->sendMessage("Thinking...")
The argument should be an array, I'm amazed it worked this way in IIS 😲
Look at https://github.com/Eleirbag89/TelegramBotPHP/blob/master/bot%20examples/webhook/updatecowsay.php for some examples
PS Can you format the code using the github code function in the editor ? It would be easier to read
$telegram->sendMessage("Thinking...")
The argument should be an array, I'm amazed it worked this way in IIS 😲Look at https://github.com/Eleirbag89/TelegramBotPHP/blob/master/bot%20examples/webhook/updatecowsay.php for some examples
PS Can you format the code using the github code function in the editor ? It would be easier to read THANK YOU! Apology for the formatting! I see now how bad it is (hard to read)! Edited original post. Will modify that string and see if that makes the difference.
Made no difference. I guess since you didn't mention composer, that means I don't have to rerun it on the new server for any kind of registration or other purposes? Just copying all the files from the old server should do?
Since it's finding the files I don't think it's a problem with composer.
So you tried to use
$content` = ['chat_id' => $chat_id, 'text' => "Thinking..."];
$telegram->sendMessage($content);
$content` = ['chat_id' => $chat_id, 'text' => $txtResponse];
$telegram->sendMessage($content);
And nothing changes ? Fan you post the stacktrace after you make this changes ?
@Eleirbag89 thank you for helping so much! As I'm sure you can tell, I'm VERY inexperienced with PHP. Knowing I'm running this on a Windows server (and I have full remote access), what is the easiest method you suggest for enabling "stacktrace"? I've been searching the web and finding a HUGE number of products. Thank you for any help you can offer!
I was thinking about some snippets of the php_errors.log file
That makes things easier! Sadly, though, the server is not writing to a log file. I suspected it might be a permissions issue but not sure. Gave modify permissions to IIS_IUSR, the web site application pool user account, and many others. Modified php.ini in both main c:\php\php7 folder, php.ini in website root, and php.ini in the folder where the PHP part of the site runs. Oh the mods:
BTW, Grimstack, I have no expectation that you me with this kind of stuff. As a fellow developer [not PHP], I totally understand how valuable your time is and not your obligation to help me with issues with my server. So yeah, you have so far gone above and beyond with how much you helped so far and I really really appreciate that!
Looking at the following code in my little PHP file that basically receives msg from telegram, sends string to my classic ASP application, receives string answer back from classic ASP, and sends it on to Telegram, I have a question:
// Send this message on to Classic ASP's $url and get response
$txtResponse = file_get_contents($url . "&txtMsg=" . urlencode($txtToSend));
// Pass response back to Telegram
$telegram->sendMessage($txtResponse);
This also seems to be an issue with using sendMessage to send non-array? Maybe it worked [totally fine] before because of older version of PHP I was using? Using 7.0 now. How can I modify that last line of code to send that one string as a PHP array?
I'm a little bit confused. sendMessage take as input an array because the telegram API need it that way. You need to have a chat_id key the text key, like the examples I gave you early.
Sorry for confusion. I just re-checked the code and you are right. I did make that $txtToSend an array by using
$content = array('chat_id' => $chat_id, 'text' => $toTelegram);
And because the code did not change since moving servers AND since logs will not write, I think this is a server config issue; maybe permissions. I'll look again in windows logs to see if any write errors. Not sure what else to do.
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.
Hi -
Primary question: Do I need to re-run composer since moving files to new server?
A little over a year ago, I used your library to get my telegrambot running on IIS (Windows server). This week I moved to another server/host.
Can't seem to get it running again without errors. Here are some things I did so far:
Errors I'm getting (source code of my small PHP file are below this error section):
FROM IIS: 2020-08-11 06:36:48 GET /telegrambot/empathybot.php - 80 - 64.207.225.186 HTTP/1.1 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64;+rv:79.0)+Gecko/20100101+Firefox/79.0 - empathybot.net 404 0 0 277 /telegrambot/empathybot.php - /telegrambot/empathybot.php 184.175.105.38
FROM php_errors.log: [11-Aug-2020 06:40:57 UTC] PHP Warning: include(): Failed opening '/vendor/autoload.php' for inclusion (include_path='.;C:\php\pear') in C:\home\empathybot.net\wwwroot\TelegramBot\EmpathyBot.php on line 8 [11-Aug-2020 06:40:57 UTC] PHP Fatal error: Uncaught Error: Class 'Telegram' not found in C:\home\empathybot.net\wwwroot\TelegramBot\EmpathyBot.php:18 Stack trace:
0 {main}
thrown in C:\home\empathybot.net\wwwroot\TelegramBot\EmpathyBot.php on line 18 [11-Aug-2020 06:41:47 UTC] PHP Fatal error: Uncaught TypeError: Argument 1 passed to Telegram::sendMessage() must be of the type array, string given, called in C:\home\empathybot.net\wwwroot\TelegramBot\EmpathyBot.php on line 29 and defined in C:\home\empathybot.net\wwwroot\TelegramBot\vendor\eleirbag89\telegrambotphp\Telegram.php:176 Stack trace:
0 C:\home\empathybot.net\wwwroot\TelegramBot\EmpathyBot.php(29): Telegram->sendMessage('Thinking...')
1 {main}
thrown in C:\home\empathybot.net\wwwroot\TelegramBot\vendor\eleirbag89\telegrambotphp\Telegram.php on line 176
EMPATHYBOT.PHP contents: