Closed igimastudio closed 8 years ago
I just try to setWebHook and used set.php from example this part $telegram = new Longman\TelegramBot\Telegram($API_KEY, $BOT_NAME); is ok $result = $telegram->setWebHook($hook_url); is error
That's strange... I don't understand how the first command can be ok but then it doesn't find the method 😕
To maybe help us, could you enter the following line directly after the $telegram = ...
line and post the result here when you open the URL to your set.php
:
die(var_dump($telegram));
object(Longman\TelegramBot\Telegram)#2 (6) { ["api_key":protected]=> string(45) "**_MY_APIKEY*******" ["input":protected]=> NULL ["commands_dir":protected]=> array(0) { } ["update":protected]=> NULL ["log_requests":protected]=> NULL ["log_path":protected]=> NULL }
Right, so you have a valid object. @MBoretto Any idea why it doesn't find the method?!
Seems impossible also to me! php version system ?
PHP 5.6.19
@igimastudio Have you managed to find out what the problem is/was? For us it's still a mystery why you get this error...
Are you maybe including the vendor autoloader multiple times?!
@igimastudio If this is still an issue for you, feel free to reopen.
This happened to me as well. Object created, but found the error:
PHP Fatal error: Call to undefined method Longman\TelegramBot\Telegram::handleGetUpdates() in /var/www/redacted/getUpdateCLI.php on line 22
Here is the getUpdateCLI.php code:
#!/usr/bin/env php
<?php
require __DIR__ . '/vendor/autoload.php';
$API_KEY = 'redacted:redacted';
$BOT_NAME = 'redactedBot';
$mysql_credentials = [
'host' => 'localhost',
'user' => 'root',
'password' => 'redacted',
'database' => 'redacted',
];
try {
// Create Telegram API object
$telegram = new Longman\TelegramBot\Telegram($API_KEY, $BOT_NAME);
// Enable MySQL
$telegram->enableMySQL($mysql_credentials);
// Handle telegram getUpdate request
$telegram->handleGetUpdates();
} catch (Longman\TelegramBot\Exception\TelegramException $e) {
// log telegram errors
echo $e;
}
Fixed. I created the composer.json manually (following README.md) and for some reason it didn't work. I then removed all the files, and use the composer require longman/telegram-bot
method and it just works.
@lawrencegs Do you know what was different in the automatically generated composer.json file?
I still can't understand how this happens.
What about put \ in front of longman?
$telegram = new \Longman\TelegramBot\Telegram($API_KEY, $BOT_NAME);
I have same problem.
Fatal error: Class 'Longman\TelegramBot\TelegramLog' not found in hook.php on line 35
Also I've noticed setWebHook
worked correctly, but when i'm trying to unset it, unsetWebHook
function is undefined. The set and unset methods are defined in same file.
Some context or something would be very helpful here. What exactly did you try and where did the error appear?