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

Fatal error: Call to undefined method Longman\TelegramBot\Telegram::setWebHook() #153

Closed
igimastudio opened this issue Apr 19, 2016 · 14 comments

Comments

@igimastudio
Copy link

No description provided.

@noplanman
Copy link
Member

Some context or something would be very helpful here.
What exactly did you try and where did the error appear?

@igimastudio
Copy link
Author

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

@noplanman
Copy link
Member

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));

@igimastudio
Copy link
Author

object(Longman\TelegramBot\Telegram)#2 (6) { ["api_key":protected]=> string(45) "_MY_API_KEY_*" ["input":protected]=> NULL ["commands_dir":protected]=> array(0) { } ["update":protected]=> NULL ["log_requests":protected]=> NULL ["log_path":protected]=> NULL }

@noplanman
Copy link
Member

Right, so you have a valid object.
@MBoretto Any idea why it doesn't find the method?!

@MBoretto
Copy link
Collaborator

MBoretto commented May 1, 2016

Seems impossible also to me! php version system ?

@igimastudio
Copy link
Author

PHP 5.6.19

@noplanman
Copy link
Member

noplanman commented May 16, 2016

@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?!

@noplanman
Copy link
Member

@igimastudio If this is still an issue for you, feel free to reopen.

@lawrencegs
Copy link

lawrencegs commented Jul 23, 2016

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;
}

@lawrencegs
Copy link

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.

@noplanman
Copy link
Member

@lawrencegs Do you know what was different in the automatically generated composer.json file?

I still can't understand how this happens.

@MBoretto
Copy link
Collaborator

What about put \ in front of longman?

 $telegram = new \Longman\TelegramBot\Telegram($API_KEY, $BOT_NAME);

@hectorfarahani
Copy link

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.

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

No branches or pull requests

5 participants